An interface naming should have a much deeper meaning than just specifying or not putting an “I” at the beginning of a name.
Neither "Fruit" nor "IFruit" would matter to me as an interface. This is because it is much more like a class. Classes define things, while interfaces must define functionality.
The naming convention "I" helps distinguish between classes and interfaces, so development is a little easier. And although this is not required, it certainly helps to avoid common object-oriented headaches. C #, like Java, only allows inheritance from one base class. But you can implement as many interfaces as you want. The caveat is that if you inherit a class and implement one or more interfaces, the base class must be named first (i.e. the Trout class: Fish, ISwimmer, IDiver ...).
I really like to call my interfaces based on what functions they provide and what type of interface they have (for example, animated or inanimate interfaces).
If you focus on the functionality provided by the interface, you can quickly determine the name for the interface. It will also help you quickly find out if your interface defines unrelated functions.
Interfaces that define inanimate objects (i.e. things that cannot act on their own) ... I like to call them ... capable at the end of IPrintable (like a document, invoice) IPlayable (like Instrument, MediaPlayer) ISavable (e.g. document, image) IEdible (e.g. fruit, beef) IDrivable (e.g. car) IFlyable (e.g. Plane)
Interfaces that define animated objects (i.e. things that act on their own) ... I like to call them ... er at the end of ISwimer (e.g. fish, dog, duck) IDiver (e.g. Fish, Duck) IFlyer (e.g. Pilot) IDriver (e.g. NascarDriver)
In the end, the naming convention "I" helps distinguish between interfaces and classes. But it makes sense to add additional naming logic, except as soon as an “I” at the beginning.
Gregor Aug 21 '14 at 2:09 a.m. 2014-08-21 02:09 a.m.
source share