Barney,
This is the first I've seen/heard a "super" qualifier.  What does it point
to/stand for?

Andy
  -----Original Message-----
  From: Barney Boisvert [mailto:[EMAIL PROTECTED]
  Sent: Wednesday, February 25, 2004 4:18 PM
  To: CF-Talk
  Subject: RE: extends + init() = returntype confusion

  First, IMHO, having init() return a reference to 'this' is bad style.  It
  only makes things more confusing.

  But to answer your question, you should have init() return the type of the
  current CFC.  When you call super.init(), you shouldn't be returning.  ALL
  your init methods should follow this format:

  <cffunction name="init" ... Returntype="typeOfThisCFC">
    <cfargument ... />
    ...
    <cfset var ... />
    ...
    <cfset super.init() />

    <!--- any initialization for this object --->

    <cfreturn this />
  </cffunction>

  Super.init() should ALWAYS be the first thing in the method, except for
  'var' declarations, if you need any.

  Cheers,
  barneyb

  > -----Original Message-----
  > From: Jamie Jackson [mailto:[EMAIL PROTECTED]
  > Sent: Wednesday, February 25, 2004 2:09 PM
  > To: CF-Talk
  > Subject: CFC: extends + init() = returntype confusion
  >
  > This could be a dumb question, but I'm 2 days into putting CFCs to
  > real 00 use.
  >
  > When you are extending a component (with "extends"), and you are also
  > using the init() function convention, do you need to override the
  > init() function for all children (in order to get the correct
  > returntype)? If so, seems you could use introspection in the parent
  > class to dynamically determing the return type, so that each child
  > would correctly inherit the init().
  >
  > So am I off-track? What's the normal way to do it?
  >
  > Thanks,
  > Jamie
  >
  >
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to