Monday, August 08, 2005

Naming interfaces and classes.

When reading these blogs I started to think about the concept of prefixing interfaces with an I. The I is meant to make it clear to the programmer that it is in fact an interface he is using.

http://www.jnsk.se/weblog/posts/iprefix.htm
http://www.bloglines.com/blog/IngoLundberg?id=5

Prefixing interfaces has, as I see it, two disadvantages: First of all it gives the impression that the interface is a secondary thing, and that there must be a more important class behind it.
When you first see IList you wonder; is there a List as well? The fact is that IList is a List and the I only confuses the user. This leads me to my second point. The unexperiensed programmer might have heard that designing your code with interfaces is a good thing. I have seen programs constructed only using classes, and thereafter added interfaces to all classes with the I prefix. The fact is that interfaces do not make much sense if they are not suppossed to be implemented by more than one class.

No comments:

Post a Comment