I agree completely with this.

At the very least overuse of extends means that you'll be spending
significant time attempting to deal with/prevent naming conflicts -
otherwise you'll be unintentionally overwriting functions from the
extended component.

The only exception I make generally is for a "root" component that all
components extend.  (CF actually does this automatically by itself in
fact).  In that root component I place all those functions common to all
components (I create a unique value to use as a lock name, set a "null"
value indicating whether a component has been initialized and so forth).
Other folks have place "OnlyProperties()" output methods (useful for
webservices) and common debugging functions (Dump(), for example) in
there as well.

This root component is generally smallish however - just the basics.  If
you can ever say "I'll only need that in some components" then,
generally, it doesn't belong in the root.

Jim Davis

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf
> Of Nathan Dintenfass
> Sent: Friday, November 21, 2003 2:33 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [CFCDev] Using components
> 
> I have to throw in the obligatory "best practice" reminder that
EXTENDS
> should not be used to get code-reuse.  Instead, EXTENDS should be used
> when
> you have an "is-a" relationship.  A classic example is a User
component
> and
> then a Manager component that extends User -- Manager is a User.
> 
> Manager is not a "library of UDFs I like to use" -- which is what I
often
> see when extends is used just for code reuse.
> 
> Instead use what the OO folks here call "composition" -- which is just
a
> fancy way of saying use other components inside your components to use
the
> code of those components.
> 
> See the archives of the list (and the KB at MACR.com) for extensive
> discussion on this topic.
> 
> 
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > Behalf Of Michael Collins
> > Sent: Friday, November 21, 2003 11:28 AM
> > To: 'Nathan Dintenfass '; '[EMAIL PROTECTED] '
> > Subject: RE: [CFCDev] Using components
> >
> >
> > You might also look at using the extends attribute of the
cfcomponent.
> >
> > Nice way to tie together some common functionality but then
> > extend for each specifc site.
> > >
> 
> ----------------------------------------------------------
> 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).
> 
> An archive of the CFCDev list is available at www.mail-
> archive.com/[EMAIL PROTECTED]


----------------------------------------------------------
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).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to