You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Ersin Er <er...@gmail.com> on 2005/10/13 10:02:39 UTC

Interface/Class naming inconsistencies

Hi,

It seems that we do not have a consistent naming convention for
interfaces and their implementor classes. For example, when the
interface is named Foo, we may have implementor classes named like
FooImpl, BaseFoo, DefaultFoo, etc.

Which one do you think is correct (or makes sense the most)?

Cheers.
--
Ersin

Re: Interface/Class naming inconsistencies

Posted by Trustin Lee <tr...@gmail.com>.
2005/10/13, Ersin Er <er...@gmail.com>:
>
> > I don't like DefaultFoo much because 'Default' sounds a little bit
> weird. I
> > use Default when I cannot find any good concrete name.
>
> Maybe, we do not need an interface if we cannot find a good concrete name?


Yes, it might be true in many cases, especially when we create a domain
immutable entity. Is is just like SUN didn't make String an interface and
provide DefaultString or something like that.

Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/

Re: Interface/Class naming inconsistencies

Posted by Ersin Er <er...@gmail.com>.
Thanks for response Trustin. I wrote a tiny inside the quote.

On 10/13/05, Trustin Lee <tr...@gmail.com> wrote:
> 2005/10/13, Ersin Er <er...@gmail.com>:
> > It seems that we do not have a consistent naming convention for
> > interfaces and their implementor classes. For example, when the
> > interface is named Foo, we may have implementor classes named like
> > FooImpl, BaseFoo, DefaultFoo, etc.
> >
> > Which one do you think is correct (or makes sense the most)?
>
> There are a few names I like:  AbstractFoo, BaseFoo, or ConcreteNameFoo
>
> * AbstractFoo - it is an abstract class which provides some common
> implementation.
> * BaseFoo - it is similar to AbstractFoo but it is not abstract at all, but
> expecting somebody to extend it.
> * ConcreteNamefoo (e.g. ArrayList implements List) - it is always a good
> idea to give it the most concrete name.
>
> I don't like DefaultFoo much because 'Default' sounds a little bit weird.  I
> use Default when I cannot find any good concrete name.

Maybe, we do not need an interface if we cannot find a good concrete name?

> I prefer DefaultFoo
> to FooImpl on the other hand because 'Impl' makes me feel that I'm dealing
> with low-level stuff.  (This is just a personal feeling! ;)
>
> Cheers,
> Trustin
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/


--
Ersin

Re: Interface/Class naming inconsistencies

Posted by Trustin Lee <tr...@gmail.com>.
2005/10/13, Ersin Er <er...@gmail.com>:
>
> It seems that we do not have a consistent naming convention for
> interfaces and their implementor classes. For example, when the
> interface is named Foo, we may have implementor classes named like
> FooImpl, BaseFoo, DefaultFoo, etc.
>
> Which one do you think is correct (or makes sense the most)?


There are a few names I like: AbstractFoo, BaseFoo, or ConcreteNameFoo

* AbstractFoo - it is an abstract class which provides some common
implementation.
* BaseFoo - it is similar to AbstractFoo but it is not abstract at all, but
expecting somebody to extend it.
* ConcreteNamefoo (e.g. ArrayList implements List) - it is always a good
idea to give it the most concrete name.

I don't like DefaultFoo much because 'Default' sounds a little bit weird. I
use Default when I cannot find any good concrete name. I prefer DefaultFoo
to FooImpl on the other hand because 'Impl' makes me feel that I'm dealing
with low-level stuff. (This is just a personal feeling! ;)

Cheers,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/

Re: Interface/Class naming inconsistencies

Posted by Bruce Rosenthal <br...@comcast.net>.
Really more a matter of consistency, so everyone can play.

Afterall, "What's in a *name*? That which we call a *rose* By *any* 
*other* word would smell as
sweet." --From Romeo and Juliet (II, ii, 1-2) *...*

jlopes@br.ibm.com wrote:

>
> >Up to me, <InterfaceName>Impl naming pattern for concrete classes
> >seems very ugly. This may only apply when you have a factory like
> >Factory.create<InterfaceName> (when we have only one default
> >implementor of an interface) so that you do not create instances using
> >that naming scheme all around your code. Otherwise, I favor Trustin's
> >approach.
>
> Agree, <InterfaceName>Impl should only be used inside a singleton factory.
>
> >On 10/17/05, Bruce Rosenthal <br...@comcast.net> wrote:
> >> I was in a SW engr enterprise that had the classname used as the
> >> Interface and classnameImpl as the implemented class. Everyone knew 
> what
> >> to expect, and so the code evolution had no problems really.
> >>
> >> 4WTIW
>
> >--
> >Ersin
>

Re: Interface/Class naming inconsistencies

Posted by jl...@br.ibm.com.
>Up to me, <InterfaceName>Impl naming pattern for concrete classes
>seems very ugly. This may only apply when you have a factory like
>Factory.create<InterfaceName> (when we have only one default
>implementor of an interface) so that you do not create instances using
>that naming scheme all around your code. Otherwise, I favor Trustin's
>approach.

Agree, <InterfaceName>Impl should only be used inside a singleton factory.

>On 10/17/05, Bruce Rosenthal <br...@comcast.net> wrote:
>> I was in a SW engr enterprise that had the classname used as the
>> Interface and classnameImpl as the implemented class. Everyone knew 
what
>> to expect, and so the code evolution had no problems really.
>>
>> 4WTIW

>--
>Ersin


Re: Interface/Class naming inconsistencies

Posted by Ersin Er <er...@gmail.com>.
Up to me, <InterfaceName>Impl naming pattern for concrete classes
seems very ugly. This may only apply when you have a factory like
Factory.create<InterfaceName> (when we have only one default
implementor of an interface) so that you do not create instances using
that naming scheme all around your code. Otherwise, I favor Trustin's
approach.

On 10/17/05, Bruce Rosenthal <br...@comcast.net> wrote:
> I was in a SW engr enterprise that had the classname used as the
> Interface and classnameImpl as the implemented class. Everyone knew what
> to expect, and so the code evolution had no problems really.
>
> 4WTIW

--
Ersin

Re: Interface/Class naming inconsistencies

Posted by Bruce Rosenthal <br...@comcast.net>.
I was in a SW engr enterprise that had the classname used as the 
Interface and classnameImpl as the implemented class. Everyone knew what 
to expect, and so the code evolution had no problems really.

4WTIW

Jérôme Baumgarten wrote:

> IBM folks do the same, they put an uppercase i in front of interface 
> names.
>
> Jerome
>
> On 10/13/05, *Emmanuel Lecharny* < elecharny@gmail.com 
> <ma...@gmail.com>> wrote:
>
>     On Thu, 2005-10-13 at 11:02 +0300, Ersin Er wrote:
>     > Hi,
>     >
>     > It seems that we do not have a consistent naming convention for
>     > interfaces and their implementor classes. For example, when the
>     > interface is named Foo, we may have implementor classes named like
>     > FooImpl, BaseFoo, DefaultFoo, etc.
>     >
>     > Which one do you think is correct (or makes sense the most)?
>
>     well, that's a good question... Personnaly, I like to add a I to
>     interface names (IFoo), but this is a kind of M$ hungarylish
>     footprint.
>
>     So FooImpl seems to be the best solution to me, but that's just my own
>     personnal opinion.
>
>     >
>     > Cheers.
>     > --
>     > Ersin
>
>
>

Re: Interface/Class naming inconsistencies

Posted by Jérôme Baumgarten <jb...@gmail.com>.
IBM folks do the same, they put an uppercase i in front of interface names.

Jerome

On 10/13/05, Emmanuel Lecharny <el...@gmail.com> wrote:
>
> On Thu, 2005-10-13 at 11:02 +0300, Ersin Er wrote:
> > Hi,
> >
> > It seems that we do not have a consistent naming convention for
> > interfaces and their implementor classes. For example, when the
> > interface is named Foo, we may have implementor classes named like
> > FooImpl, BaseFoo, DefaultFoo, etc.
> >
> > Which one do you think is correct (or makes sense the most)?
>
> well, that's a good question... Personnaly, I like to add a I to
> interface names (IFoo), but this is a kind of M$ hungarylish footprint.
>
> So FooImpl seems to be the best solution to me, but that's just my own
> personnal opinion.
>
> >
> > Cheers.
> > --
> > Ersin
>
>
>

Re: Interface/Class naming inconsistencies

Posted by Emmanuel Lecharny <el...@gmail.com>.
On Thu, 2005-10-13 at 11:02 +0300, Ersin Er wrote:
> Hi,
> 
> It seems that we do not have a consistent naming convention for
> interfaces and their implementor classes. For example, when the
> interface is named Foo, we may have implementor classes named like
> FooImpl, BaseFoo, DefaultFoo, etc.
> 
> Which one do you think is correct (or makes sense the most)?

well, that's a good question... Personnaly, I like to add a I to
interface names (IFoo), but this is a kind of M$ hungarylish footprint.

So FooImpl seems to be the best solution to me, but that's just my own
personnal opinion.

> 
> Cheers.
> --
> Ersin