Placing both an interface and an implementation is a common place and does not seem to be a problem.
Take, for example, the Java API - most classes have both interfaces and their implementations included in the same package.
Take, for example, the java.util package:
It contains interfaces such as Set , Map , List , and also has implementations such as HashSet , HashMap and ArrayList .
In addition, Javadocs are designed to work well under these conditions, since it divides the documentation into representations of interfaces and classes when displaying package contents.
Having packages for interfaces only can be a bit overwhelming if there aren't a huge number of interfaces. But dividing interfaces into native packages just to do this sounds like bad practice.
If differentiating an interface name from an implementation is necessary, one could have a naming convention to facilitate identification of interfaces:
Interface name prefix with I This approach is applied with interfaces in the .NET framework. It would be fairly easy to say that IList is an interface to the list.
Use the suffix - able . This approach is often found in the Java API, for example Comparable , Iterable and Serializable , to name a few.
coobird Jun 17 '09 at 3:44 2009-06-17 03:44
source share