Some folks feel that the code that consumes an interface should not have
to be aware that they are dealing with an interface, rather than a
class.  The idea is that using an interface is an implementation detail
that should be encapsulated away from the user of the interface.  If I
have a Person interface, I shouldn't have to care whether or not the
instance I'm dealing with is an interface or a concrete class.

 

In practice, however, it is very helpful for the implementer of the
interface (i.e. the framework developer) to know about the interface
structure, so the "I" notation is helpful from the framework developer
perspective, but harmful from the end-deveoper-user's perspective.  I
use the "I" notation in my code, but I'm not publishing it for further
consumption.  If I were, I'd probably not use the "I" for externally
published APIs.  But internally it is a very valuable technique for
distinguishing interfaces.

 

BTW, back in my COM days, all interfaces had an "I" in front of them -
IUnknown, IDispatch, IWhatever.  It didn't hurt COM at all.

 

-----Original Message-----
From: Tapestry Forum User [mailto:[EMAIL PROTECTED] 
Sent: Sunday, April 24, 2005 9:13 AM
To: [email protected]
Subject: If we call it Tapestry 4.0, not 3.x, Maybe we would do much

 


kent at cpttm.org.mo wrote:


Using "I" is bad because it violates the DRY (Don't Repeat Yourself)
principle. If the fact that Foo is an interface is already stated 
in:

interface Foo { ... }

There is no need to state it again in its name. Similarly, you won't
duplicate the methods in Foo into its name, right?



I think it may have come from C++ where the keyword class is used both
for interfaces, abstract classes, and concrete classes.

However, I would prefer to have the I prefix. Sure, you may have the
word "interface" at the definition, but what about everywhere else you
are using that interface? Without the "I" you have no way of knowing
it's an interface, unless you specifically look for where your IDE
specifies it as one.

Ever try to instantiate an interface when using someone elses API? Even
when using an API I wrote, it helps my thought process to visually see
where interfaces are used when looking at a block of code.



  _____  


--
Chris Yates
www.TapestryForums.com 


Sent using Mail2Forum (http://www.mail2forum.com) Read this topic online
here: http://www.tapestryforums.com/viewtopic.php?p=1667#1667

Reply via email to