|
Home > Archive > Apache Directory Project > October 2005 > Interface/Class naming inconsistencies
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Interface/Class naming inconsistencies
|
|
| Ersin Er 2005-10-13, 5:45 pm |
| SGksCgpJdCBzZWVtcyB0aGF0IHdlIGRvIG5vdCBo
YXZlIGEgY29uc2lzdGVudCBuYW1pbmcgY29u
dmVudGlvbiBmb3IKaW50ZXJmYWNlcyBhbmQgdGhl
aXIgaW1wbGVtZW50b3IgY2xhc3Nlcy4gRm9y
IGV4YW1wbGUsIHdoZW4gdGhlCmludGVyZmFjZSBp
cyBuYW1lZCBGb28sIHdlIG1heSBoYXZlIGlt
cGxlbWVudG9yIGNsYXNzZXMgbmFtZWQgbGlrZQpG
b29JbXBsLCBCYXNlRm9vLCBEZWZhdWx0Rm9v
LCBldGMuCgpXaGljaCBvbmUgZG8geW91IHRoaW5r
IGlzIGNvcnJlY3QgKG9yIG1ha2VzIHNlbnNl
IHRoZSBtb3N0KT8KCkNoZWVycy4KLS0KRXJzaW4K
| |
| Trustin Lee 2005-10-13, 5:45 pm |
| 2005/10/13, Ersin Er <ersin.er-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
>
> 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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2R5IHRv
IGV4dGVuZCBpdC4KPiAqIENvbmNyZXRlTmFtZWZv
byAoZS5nLiBBcnJheUxpc3QgaW1wbGVtZW50
cyBMaXN0KSAtIGl0IGlzIGFsd2F5cyBhIGdvb2QK
PiBpZGVhIHRvIGdpdmUgaXQgdGhlIG1vc3Qg
Y29uY3JldGUgbmFtZS4KPgo+IEkgZG9uJ3QgbGlr
ZSBEZWZhdWx0Rm9vIG11Y2ggYmVjYXVzZSAn
RGVmYXVsdCcgc291bmRzIGEgbGl0dGxlIGJpdCB3
ZWlyZC4gIEkKPiB1c2UgRGVmYXVsdCB3aGVu
IEkgY2Fubm90IGZpbmQgYW55IGdvb2QgY29uY3Jl
dGUgbmFtZS4KCk1heWJlLCB3ZSBkbyBub3Qg
bmVlZCBhbiBpbnRlcmZhY2UgaWYgd2UgY2Fubm90
IGZpbmQgYSBnb29kIGNvbmNyZXRlIG5hbWU/
Cgo+IEkgcHJlZmVyIERlZmF1bHRGb28KPiB0byBG
b29JbXBsIG9uIHRoZSBvdGhlciBoYW5kIGJl
Y2F1c2UgJ0ltcGwnIG1ha2VzIG1lIGZlZWwgdGhh
dCBJJ20gZGVhbGluZwo+IHdpdGggbG93LWxl
dmVsIHN0dWZmLiAgKFRoaXMgaXMganVzdCBhIHBl
cnNvbmFsIGZlZWxpbmchIDspCj4KPiBDaGVl
cnMsCj4gVHJ1c3Rpbgo+IC0tCj4gd2hhdCB3ZSBj
YWxsIGh1bWFuIG5hdHVyZSBpcyBhY3R1YWxs
eSBodW1hbiBoYWJpdAo+IC0tCj4gaHR0cDovL2ds
ZWFteW5vZGUubmV0LwoKCi0tCkVyc2luCg==
| |
| Trustin Lee 2005-10-13, 5:45 pm |
| 2005/10/13, Ersin Er <ersin.er-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
>
> weird. I
>
> 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/
| |
| Emmanuel Lecharny 2005-10-13, 5:45 pm |
| 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
| |
| Jérôme Baumgarten 2005-10-19, 5:46 pm |
| IBM folks do the same, they put an uppercase i in front of interface names.
Jerome
On 10/13/05, Emmanuel Lecharny <elecharny-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> On Thu, 2005-10-13 at 11:02 +0300, Ersin Er wrote:
>
> 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.
>
>
>
>
| |
| Bruce Rosenthal 2005-10-19, 5:46 pm |
| 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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> <mailto:elecharny-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> wrote:
>
> On Thu, 2005-10-13 at 11:02 +0300, Ersin Er wrote:
>
> 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.
>
>
>
>
| |
| Ersin Er 2005-10-19, 5:46 pm |
| VXAgdG8gbWUsIDxJbnRlcmZhY2VOYW1lPkltcGwg
bmFtaW5nIHBhdHRlcm4gZm9yIGNvbmNyZXRl
IGNsYXNzZXMKc2VlbXMgdmVyeSB1Z2x5LiBUaGlz
IG1heSBvbmx5IGFwcGx5IHdoZW4geW91IGhh
dmUgYSBmYWN0b3J5IGxpa2UKRmFjdG9yeS5jcmVh
dGU8SW50ZXJmYWNlTmFtZT4gKHdoZW4gd2Ug
aGF2ZSBvbmx5IG9uZSBkZWZhdWx0CmltcGxlbWVu
dG9yIG9mIGFuIGludGVyZmFjZSkgc28gdGhh
dCB5b3UgZG8gbm90IGNyZWF0ZSBpbnN0YW5jZXMg
dXNpbmcKdGhhdCBuYW1pbmcgc2NoZW1lIGFs
bCBhcm91bmQgeW91ciBjb2RlLiBPdGhlcndpc2Us
IEkgZmF2b3IgVHJ1c3RpbidzCmFwcHJvYWNo
LgoKT24gMTAvMTcvMDUsIEJydWNlIFJvc2VudGhh
bCA8YnJvc2VudGhAY29tY2FzdC5uZXQ+IHdy
b3RlOgo+IEkgd2FzIGluIGEgU1cgZW5nciBlbnRl
cnByaXNlIHRoYXQgaGFkIHRoZSBjbGFzc25h
bWUgdXNlZCBhcyB0aGUKPiBJbnRlcmZhY2UgYW5k
IGNsYXNzbmFtZUltcGwgYXMgdGhlIGltcGxl
bWVudGVkIGNsYXNzLiBFdmVyeW9uZSBrbmV3IHdo
YXQKPiB0byBleHBlY3QsIGFuZCBzbyB0aGUg
Y29kZSBldm9sdXRpb24gaGFkIG5vIHByb2JsZW1z
IHJlYWxseS4KPgo+IDRXVElXCgotLQpFcnNp
bgo=
| |
| jlopes-xuelUoVDAHHQT0dZR+AlfA@public.gmane.org 2005-10-19, 5:46 pm |
| >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 <brosenth-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote:
what[vbcol=seagreen]
[vbcol=seagreen]
>--
>Ersin
| |
| Bruce Rosenthal 2005-10-19, 5:46 pm |
| 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-xuelUoVDAHHQT0dZR+AlfA@public.gmane.org wrote:
>
>
> Agree, <InterfaceName>Impl should only be used inside a singleton factory.
>
> what
>
>
|
|
|
|
|