On Friday, Aug 8, 2003, at 13:57 US/Pacific, John Farrar wrote:
Here goes a bomb... you could create the logic and create a cfc that does
the display and "inherits" the logic.

Reuse of code through inheritance is poor practice (well, you knew *someone* was going to object to your suggestion!) and it makes no sense anyway: inherited CFCs should relate to their parent as "IS-A". Otherwise you should be using composition (or other technique).


DisplayMamal is a LogicMammal approach.

But the "IS-A" relationship does not really hold here! A DisplayMammal isn't a mammal at all, it's a type of display object - it's an object that responds to rendering requests by invoking data methods on some other object.


Consider:
        Man is-a LogicMammal
so you could reasonably have Man extend LogicMammal.

What is a DisplayMan? Does it extend Man or DisplayMammal? DisplayMan is more likely to be a specialization of DisplayMammal but you'd need to provide it a Man instance to render.

You'd be on much safer OO ground with this sort of hierarchy:

    DisplayMammal refers to instance of LogicMammal
         ^                                   ^
       extends                            extends
         |                                   |
    DisplayMan     refers to instance of  LogicMan

You would create an instance of DisplayMan and initialize it with the instance of LogicMan that it is intended to render (or pass in the instance to each 'render' request).

DisplayMammal would have the basic formatting for primitive aspects of LogicMammal, e.g., normal body temperature, number of legs etc and then DisplayMan would add or customize formatting for LogicMan-specific aspects.

Make sense?

Sean A Corfield -- http://www.corfield.org/blog/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' in the message of the email.


CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

Reply via email to