Naming is an important part of creating clean, readable code.  The de facto standard for naming interfaces in the .NET community has always been INounPhrase, such as IEnumerable, IDbConnection, etc.  However, Rob Simmons and others have recently been advocating using IVerbPhrase instead, such as IAmEnumerable, IProvideWidgets, etc.  At first I was resistant to this change, but I’m starting to come around. 

Note: this is not my usual type of blog post.  This is more me thinking out loud than anything else.  If you’re looking for solid conclusions, you should stop reading now. 🙂

The up side to the IVerbPhrase naming scheme is that type declarations read much more fluently than before.  Consider a message or event handler, one using INounPhrase, and the other using IVerbPhrase:

public class CustomerCreatedHandler : IHandler<CustomerCreatedEvent>
{
...
}

public class CustomerCreatedHandler : IHandle<CustomerCreatedEvent>
{
...
}

The first is certainly understandable, but the declaration doesn’t really read all that well if you treat it as a statement: “CustomerCreatedHandler: I handler… CustomerCreatedEvent…”  The later reads very well though: “CustomerCreatedHandler: I handle CustomerCreatedEvent.”   It’s a subtle difference, but I do prefer the way the later reads.

Like all things in development though, it’s easy to come up with a counter-argument.  Consider the example of a repository class.  Using IVerbPhrase here doesn’t feel nearly as clean:

public class UserRepository : IRepository<User>
{
...
}

public class UserRepository : IAmARepositoryFor<User>
{
}

It also feels a bit odd to me when I use interfaces named with IVerbPhrase as parameters:

public SomeService(IDatabaseUpdater databaseUpdater)
{
...
}

public SomeService(IUpdateDatabases databaseUpdater) 
{
...
}

The former feels more natural to me, though it’s hard to express exactly why.  For some reason, the later declaration makes me feel like I’m depending on an “ability” more than a type, though perhaps that’s actually a good way to look at things…

Anyway, what does everyone else think?  The base class library and most of the .NET community uses the INounPhrase scheme, but I’m seeing more and more people that are starting to use IVerbPhrase.