views:

159

answers:

5

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?

+13  A: 

Although hard to read, IItem would be in line with some existing "II" interfaces:

p.campbell
I was struggling to find examples that fast, but didn't succeed ... :-)
Stefan Steinegger
@Stefan: thanks, it was fun searching! :)
p.campbell
Thanks IItem it is then
Eric Anastas
+4  A: 

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.

Stefan Steinegger
+1  A: 

You can see the MS guys is using System.ComponentModel.IItemProperties

Danny Chen
A: 

Just Item, please! 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 (*cough* MFC *cough*). Prefixing types with anything is tantamount to using Hungarian notation (auuugh my eyes).

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 uglier.

Let the haters hate...

Chris Schmich
So postfixing with the full name is better than a one letter prefix?
Esteban Araya
@Esteban Araya: Sorry, I'm not sure I understand what you're saying. If you mean using dynamic languages, well, that's a whole different flamewar :)
Chris Schmich
Sorry, -1 from me, the convention within the .net framework is for interfaces to be prefixed with "I". Not doing that creates code that's not as understandable by anyone who's not you who needs to maintain your codebase in the future. Like it or loathe it, consistency is king =)
Rob
@Rob: fair enough. The post was made somewhat in jest (I stick with consistency at work, but I drop the prefix for personal projects). I guess I'm mostly sad that the BCL decided to go with this convention.
Chris Schmich
@Rob: also, I've realized over time that your argument about consistency is the same reason why writing in C/C++ can be painful. Mixing the STL, Win32, and local coding conventions changing over time is the nadir of consistency.
Chris Schmich
@Esteban is saying that you appear to have swapped a prefix `I` for a suffix `Interface`, and are regarding that as better.
AakashM
@AakashM: Ah sorry, I copy-pasted the type from the question (and apparently read way too fast). Yes, appending `Interface` is even worse. I've updated my answer.
Chris Schmich
And now what do you call the concrete class? *shudder* `ItemImpl` ?? This isn't Java! :)
AakashM
+1 for having some balls. Even though I totally disagree with you. (A coworker of mine leaves out the `I` prefix as well, and I secretly hate him for it.)
Dan Tao
@DanTao, time to beat your co-worker round the head with your coding standards doc? ;=)
Rob
I completely agree with your arguments. Really. But I can't vote for this answer, because the I for interfaces is standard in .NET. Yeah, it's the li'l brother of the Hungarian. But doing otherwise is bullshit. The world is not perfect.
Stefan Steinegger
+1. Because it's convention doesn't make it right. Nothing changes if you keep doing the same thing and there's no good reason for the 'I'. Just say no to prefixes!
kirk.burleson
+1  A: 

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.

krishna