> So back to my problem, I have a VIN number to a car and I need 
> to know if that car  is a truck and therefore if I can tow a boat with it.
Do you need to know if the car is a truck or is that just an
intermediate step on the way to finding out if you can tow a boat? If
it's not really necessary to know whether it's a truck, I think a
canTowBoats() method is the way to go.

However, I think there's another problem. You have a chicken and egg
situation. You're trying to instantiate a car and then read its
properties from the database. But you don't know what kind of car to
instantiate until you read the database!
 
> <cfset myCar = createObject("component","com.truck").init()>
> <cfset truckDAO.read(myCar,form.vin_number)>

The solution is to have your DAO instantiate the car. 

<cfset myCar = carDAO.read(form.VIN)/>

The DAO reads the database first, then instantiates either a Truck,
SUV, or SportsCar, fillls up its attributes, and returns it. You don't
know whether you got a Truck, SportsCar, or SUV (or some other
subclass of Car) back. Ideally it shouldn't matter because you'll only
be calling functions that apply to all types of cars.

If you want to know for sure that you're working with a truck (and
you're not expecting a VIN associated with non-trucks) you could have
a TruckDAO. If you pass the TruckDAO a VIN associated with a truck, it
will return a truck. If you pass it a VIN associated with a SportsCar
it would throw an exception.

You could have one part of the application that deals specifically
with trucks, and works with Truck and TruckDAO, while another part of
the application works with all cars and uses Car and CarDAO.

HTH,

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]


Reply via email to