Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Placing both the interface and the implementation is common place, and doesn't seem to be a problem.</p> <p>Take for example the Java API -- most classes have both interfaces and their implementations included in the same package. </p> <p>Take for example the <a href="http://java.sun.com/javase/6/docs/api/java/util/package-summary.html" rel="noreferrer"><code>java.util</code></a> package:</p> <p>It contains the interfaces such as <code>Set</code>, <code>Map</code>, <code>List</code>, while also having the implementations such as <code>HashSet</code>, <code>HashMap</code> and <code>ArrayList</code>.</p> <p>Furthermore, the Javadocs are designed to work well in those conditions, as it separates the documentation into the <em>Interfaces</em> and <em>Classes</em> views when displaying the contents of the package.</p> <p>Having packages only for interfaces may actually be a little bit excessive, unless there are enormous numbers of interfaces. But separating the interfaces into their own packages just for the sake of doing so sounds like bad practice.</p> <p>If differentiating the name of a interface from an implementation is necessary, one could have a naming convention to make interfaces easier to identify:</p> <ul> <li><p><em>Prefix the interface name with an <code>I</code>.</em> This approach is taken with the interfaces in the .NET framework. It would be fairly easy to tell that <code>IList</code> is an interface for a list.</p></li> <li><p><em>Use the -<code>able</code> suffix.</em> This approach is seen often in the Java API, such as <code>Comparable</code>, <code>Iterable</code>, and <code>Serializable</code> to name a few.</p></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload