Interfaces in .NET have a specific naming convention. They begin with a capital “I”, followed by some text that indicates what the interface represents. IEnumerable is a classic example; it means the implementing object can be enumerated. This naming convention, however, is pretty unique to .NET. In the Java world, interfaces do not have a special prefix to indicate that they are interfaces. Java, unlike .NET, uses two keywords, “extends” and “implements”, to indicate whether a class is participating in an inheritance hierarchy and/or representing some behavior, respectively. In .NET, we use a simple colon and rely on the ordinal position of the class/interface names that come after to indicate the same.
The prefix “I” used for interfaces is seen by many (myself included) as unnecessary. It serves no useful purpose other than to provide a visual cues to developers, allowing them to identify interfaces quickly while coding. Java IDEs typically provide these visual cues so that developers don’t have to rely on a naming convention for this purpose.
Visual Studio has visual aids as well, but they are not as obvious, in my opinion.
I do think a naming convention for interfaces is still a good idea, but I don’t think the prefix “I” is necessary. Instead, I would like to propose that interfaces be named for the behavior that the represent, starting with a prefix like “Can”, or “Will”, or “Has”, followed by a description of that behavior. For example:
- IEnumerable becomes CanEnumerate
- IDisposable becomes CanDispose
- IQueryable becomes CanQuery