Naming Interfaces


An innocent question raised by Ayende has started an interesting debate on the comments.

In short (read it all there - don’t be lazy)

Which interface name is better?

a. IRecognizeFilesThatNeedToBeIgnored

b. IIgnoreFilesSpecification

with a single method: ShouldBeIgnored(string file);

Some were in favour of a, some in favour of b.

The interesting thing is that many has offered a third option:

c. IFileFilter

Let’s group these things:

Personally I couldn’t care less which one of the first type will be used. I slightly in favour of b., as I think funny names are good. The compiler cares nothing about names, but the human mind would remember the purpose well, and a newcomer would pick it up quickly.

The second group (IFileFilter) is not good. It might get filled with a lot of methods that do file filtering.and if it’s not, I think it should reflect the intention of the implementing class.Since multiple interfaces per class are allowed, it’s ok to have specialised ones.

     Tweet Follow @kenegozi