Hi,
-
I wonder why all interfaces in the CLR BCL start with I ?I know that the word interface start with I, but class also start with C and Microsoft stop put C on all classes after MFC.Enum start with E, it doesn't mean we put E before every enum, right?I think it's time to let that old habit go, it makes the code look much better, and much easier to talk about the code without putting "Ei" before every interface we are about to say.What do you think?Thanks.
-
Readability, I guess.
C#, unlike Java, doesn't use the "extends"/"implements" keyword, but Java doesn't prefix its interfaces with "I".
So if you've got this:
class MyClass : Foo
...you've got no idea if Foo is a class or an interface.
The other reason is some kind of developer-friendly convention with COM which also had the IInterface scheme, but didn't do the same with other types. .NET builds on COM (in a way), so it's only natural to keep some of the naming system. -
W3bbo said:Readability, I guess.
C#, unlike Java, doesn't use the "extends"/"implements" keyword, but Java doesn't prefix its interfaces with "I".
So if you've got this:
class MyClass : Foo
...you've got no idea if Foo is a class or an interface.
The other reason is some kind of developer-friendly convention with COM which also had the IInterface scheme, but didn't do the same with other types. .NET builds on COM (in a way), so it's only natural to keep some of the naming system.I think it's more your second reason than your first. MS had all these developers using COM and to get them to switch to .NET they had to maintain some similarity.
VB still has separate keywords for it: inherits and implements. -
Though it's not quite an answer here's a blog post from Brad Adams on the matter, maybe it helps:
http://blogs.msdn.com/brada/archive/2004/02/03/67033.aspx -
It all sound right, but the reality is that today tools, specifically IDEs, can give us all the information we need, all with hover of a mouse (no click involve).Dexter said:Though it's not quite an answer here's a blog post from Brad Adams on the matter, maybe it helps:
http://blogs.msdn.com/brada/archive/2004/02/03/67033.aspxObject Oriented primary goal is to make programming language more human-like, and I don't see human call their dog name that start with "D" nor we name our street with "S".We understand the type of thing we talk about by its context, and if we don't understand we ask (hover with the mouse).In a new project I'm working on I stop putting "I" before every interface and I think my code is much cleaner and easy to understand and use.It's sound wired at start, but it getting right after a while.Thanks for thinking
-
The .NET Framework Design Guidelines prescribe the I before interface names... they also say that, when you have a standard implementation of an interface, the class name should be the same as the interface name without the I (e.g. IAsyncResult and AsyncResult); you can't do that if you're not using a prefix on interface names.ido.ran said:
It all sound right, but the reality is that today tools, specifically IDEs, can give us all the information we need, all with hover of a mouse (no click involve).Dexter said:*snip*Object Oriented primary goal is to make programming language more human-like, and I don't see human call their dog name that start with "D" nor we name our street with "S".We understand the type of thing we talk about by its context, and if we don't understand we ask (hover with the mouse).In a new project I'm working on I stop putting "I" before every interface and I think my code is much cleaner and easy to understand and use.It's sound wired at start, but it getting right after a while.Thanks for thinking
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.