The way I described will work, and keep the typing as tight as possible,
which is what you want.  You don't want to use any very often, because it's
the same as not even specifying a type.  The point of typing is to catch
errors in a structured way, rather than the "wait til it fails on first use"
approach.

The reason I don't like returning from init, is that it's elevates the init
method to a status that's greater than 'normal' methods, but less than a
real constructor, which is only confusing.  And at best, it'll save you the
length of the variable name + 11 characters of typing, and cost you
readability.

Also, it's inconsistent with non-CFC objects, because their constructors
CAN'T return anything, so you have to do the two line initialization.

That's 100% personal taste, and there are many who disagree with me.  I'm
not going to tell you not to do it that way (that's your decision to make),
just that I don't do it.

Cheers,
Barneyb

> -----Original Message-----
> From: Jamie Jackson [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, February 25, 2004 2:41 PM
> To: CF-Talk
> Subject: Re: extends + init() = returntype confusion
>
> On Wed, 25 Feb 2004 14:17:35 -0800, in cf-talk you wrote:
>
> >First, IMHO, having init() return a reference to 'this' is
> bad style.  It
> >only makes things more confusing.
>
> Just when I thought I had one solid convention...
>
> So what's the preferred way to do it, and why is "return this" bad?
>
> One more thing about "return this": Why not just have the "any"
> returntype in the super class, since "this" is guaranteed(?) to return
> the current type?
>
> Thanks,
> Jamie
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to