On 03-02-2011 04:14, Robin Wenger wrote:
As I noticed there are two different naming conventions for an
Interface+Implementation pair:
1.) MyClass (=Interface) + MyClassImpl (=Implementation)
or
2.) IMyClass (=Interface) + MyClass (=Implementation)
The first one is (AFAIK) from Sun Who defined originally the second one?
What is recommended (for which scenario)?
The second is part of the common hungarian naming
convention used in Windows C/C++ programming. Especially
in COM programming the IThingys are everywhere. .NET
ditched hungarian naming convention in general but kept
it for interfaces. Possibly to make it easier for
interop with COM. But very much a MS convention. It
is very rare to see it in the Java world (even though I
think there is somewhere it is used).
The first is the convention introduced by SUN for Java RMI.
Some people have suggested it being used for Java
in general, but that idea has never caught on. It is used
for RMI and not for anything else in the Java world. I
don't think I have seen it used outside of Java.
The Java coding convention:
http://www.oracle.com/technetwork/java/codeconventions-135099.html#367
just specify plain nouns in mixed case for both classes
and interfaces.
I think it is relative common for an interface Foo to
have implementing classes be either FooBar or BarFoo where
Bar somehow indicates something about the implementation.
AbstractFoo.