I want to create an interface for "Items". Typicaly I would name an interface by adding and "I" prefix to a base word. But in this case my base word already starts with an I. Here are a couple ideas I've had
- IItem: Two I's
- Iitem : Vary the case
- ItemInterface: Skip the I prefix and write out Interface
What looks the best? Has anyone else run into this problem. If so what did you do?
Although hard to read, IItem
would be in line with some existing "II
" interfaces:
- IItem in Windows Mobile 6.5
- IImplicitResourceProvider
- IISAPIRuntime
Simply IItem
. There is no need for an exception.
Interfaces start with two upper case letters (I[A-Z]), which identify them as an interface. So Item
is not an interface, but IItem
is.
According to .Net naming convention Interface name should be preceded by Capital Letter 'I' Followed by Name of interface in Camel case.
So I suggest you to to name interface Item as:
IItem
Not necessary to Mention 'Interface' at the end because The Letter 'I' at the Start itself says that it is Interface, not require to mention explicitly.
You can see the MS guys is using System.ComponentModel.IItemProperties
Edit 2016/08/12: I originally provided this answer as an alternative perspective on naming conventions. My day-to-day C# now uses I
-prefixing to keep things idiomatic and to reduce cognitive burden through consistency. I think consistency is more important than the issues I raise below. In short, stick with the conventions of the code base you're working in.
Just Item
. Not because the interface starts with an I
, but rather because prefixing classes with identifying letters is not necessary. Decorating interfaces with I
is as ugly as slapping C
before your concrete class names (a la MFC). Prefixing types with anything is as bad as using Hungarian notation.
You could argue that it actually gives you semantic value, but I'm not convinced. I have a modern IDE and I don't need my type names to be any more complex.