On Apr 6, 2005 12:32 PM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> <cfset myCar = createObject("component","com.car").init()>
> <cfset carDAO.read(myCar,form.vin_number)>
> <cfif myCar.getType() is "truck">
> <cfset myCar.towBoat()>
> <cfelse>
> Sorry, you can't tow a boat with your car
> </cfif>
Instead of asking the car what type of car it is, why don't you just
ask it whether it can tow boats?
<cfif myCar.canTowBoats()>
You can have your SUV and Truck CFCs always return true, and your
SportsCar CFC always return false. Later, if you add a Motorcycle CFC
and a Sedan CFC you don't need to change the code that works with
cars.
The code above could be rewritten like so.
<cfset carDAO.read(myCar,form.vin_number)>
<cfif myCar.canTowBoats()>
<cfset myCar.towBoat()>
<cfelse>
Sorry, you can't tow a boat with your car
</cfif>
Patrick
--
Patrick McElhaney
704.560.9117
http://pmcelhaney.weblogs.us
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]