Sean,

I am going to ask in a different way, and I would hope that you can provide a 
code example to explain you reasoning in more detail. When learning design 
patterns in Java, the book Head First Design Patterns gives a good example on 
the duck, with interfaces and implementation.

I would like for someone like yourself help us understand this in CF better, 
because I am not getting it from the technical side that you mention, call me 
stupid but I don't get it.

After reading this book, I see that when creating interfaces I can create an 
object and know that these methods are going to exist for the object. But to 
confuse the issue you say that CF doesn't need it, and I believe it provides a 
stronger mechanism for robust code.

So if we take the duck example in the book, how would you apply this in 
Coldfusion without using interfaces?



Andrew Scott
Senior Coldfusion Developer
Aegeon Pty. Ltd.
www.aegeon.com.au
Phone: +613  8676 4223
Mobile: 0404 998 273



-----Original Message-----
From: Sean Corfield [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 10 July 2007 7:00 PM
To: CF-Talk
Subject: Re: SURVEY RESULTS: Is ColdFusion OO?

On 7/10/07, Andrew Scott <[EMAIL PROTECTED]> wrote:
> Sean why are you so against this? I welcome this with great open arms...

Java needed interfaces because it is a statically typed language and
had chosen not to support multiple inheritance. It had no choice.

In ColdFusion, all type checking is done at run time. So if you use
interfaces, you will get a *runtime* check, just like all the other
checks. And if you screw up, you'll get a runtime error. If you use
interfaces, the error just has different text in it (OK, that's a
*slight* oversimplification :)

Furthermore, since CF is a dynamic language, you can change methods on
an object after constructing it, thus removing any guarantees that an
interface would buy you. You remove a method or simply replace a
method with a different signature. The interface no longer applies.

Then there's the actual details of how cfinterface performs its type
check. It requires that the function signatures match exactly, as do
the return types. That's not how interfaces work in statically typed
languages. An interface defines a constraining API, not an exact API:
you can specify arguments (in an implementation class method) that are
compatible with the interface method arguments (e.g., adding optional
arguments or using more permissive types). You can also specify more
constrained return types since those can't violate the interface
(i.e., an implementation method can return a subtype of the interface
method's return type).

Finally (thank god you say!), other dynamic OO languages don't have
interfaces - and don't need them. The only reason CF8 has interfaces
is to satisfy the CF-should-be-more-like-Java crowd. And, yes, I admit
I was the person who entered the original ER to add interfaces and,
yes, I whipped up support from the community. I regret that. I should
have left well alone. I've probably done more to cause the
CF-should-be-more-like-Java argument than anyone and that was a big
mistake on my part. I've seen the light now... I hope others do too...
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

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



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:283440
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to