I is for Interface

05/29/11

Permalink 06:44:07 pm, by truewill Email , 174 words, 390 views   English (US)
Categories: C#, .NET

I is for Interface

Some very smart people have balked at the idea of prefixing C# interfaces with the letter “I". While I dislike Hungarian notation, I am in favor of IInterfaces.

My main reason is the C# language itself. Consider this code:

public class Employee : Person

Is Person an interface or a class? Proponents of the no-I convention might say that it shouldn’t matter. In C#, though, it does matter. In a single-inheritance language, you only get one base class. Also, if I want to see all of the behavior for Employee, I may want to look at the code for Person as well if it’s a class.

Java has the implements and extends keywords; C# only has the colon (:). In Java you can identify interfaces at a glance; in C# you can’t.

My other reason is that it’s the standard. Microsoft’s conventions say to prefix interface names with the letter I. Most of the C# code I’ve seen does. Deviating from this convention can confuse developers.

I hope we can see eye to I on this.

Comments, Pingbacks:

No Comments/Pingbacks for this post yet...

Leave a comment:

Your email address will not be displayed on this site.
Your URL will be displayed.

Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>
(Line breaks become <br />)
(Set cookies for name, email and url)
(Allow users to contact you through a message form (your email will NOT be displayed.))
The name truewill is composed of two other words. What is the SECOND word?

Development Central

Development Central is the blog of Bill Sorensen, a professional software developer. Much of this will relate to C#, .NET, and OOP in general.

Disclaimer
These postings are provided "AS IS" with no warranties and confer no rights.

Search

Categories

Linkblog

b2evolution

contributors

XML Feeds

What is RSS?

Who's Online?

  • Guest Users: 3

powered by b2evolution free blog software