Ayende @ Rahien

Refunds available at head office

I understand that naming matters, so...

Which should I use?

This:

image

Or this:

image

Comments

Peter Ritchie
06/16/2008 02:02 PM by
Peter Ritchie

I would avoid IIgnoreFilesSpecification to avoid confusing it with a Specification pattern implementation.

Guy
06/16/2008 02:35 PM by
Guy

How about "IIgnorable"?

Jack
06/16/2008 02:35 PM by
Jack

I'd go with the first one, seeing the 2 I's next to each other gives me a headache. :)

jonnii
06/16/2008 02:35 PM by
jonnii

public interface IFileFilter{

bool ShouldProcess(bool file);

}

??

Rik Hemsley
06/16/2008 02:36 PM by
Rik Hemsley

Using the 'I' at the beginning of an interface name as the first person singular personal pronoun is not a naming convention I recognise so I'd prefer the latter.

Drakiula
06/16/2008 02:37 PM by
Drakiula

What about 'public interface IIgnoredFilesRecognizer'?

Rik Hemsley
06/16/2008 02:37 PM by
Rik Hemsley

Oh and I agree with jonnii - that's a much better name.

Tuna Toksoz
06/16/2008 02:38 PM by
Tuna Toksoz

Both sounded weird to me.

IIgnorableFileSpecifier? maybe?

Mike D
06/16/2008 02:43 PM by
Mike D

IFileFilter gets my vote

Julian Birch
06/16/2008 02:48 PM by
Julian Birch

I agree naming is important, but how about Predicate?

Ayende Rahien
06/16/2008 02:52 PM by
Ayende Rahien

Predicate is useless, it doesn't tell me what it does.

orcmid
06/16/2008 03:02 PM by
orcmid

We are trapped in the world of having to name a method and a class to get it right. Wonderful. There are days when I wonder whether we should bring back pure functions and maybe namespaces.

Without more context, this is difficult, but the first one seems to provide information and the second is simply a mystery (requiring far more context to be sensible).

IFileFilter seems too broad and IIgnorable seems even more so.

What I don't get about this interface is (1) that it is an interface but (2) we have to provide a file name. So what kind of object has that interface?

Juliano Nunes
06/16/2008 03:03 PM by
Juliano Nunes

IFileFilter or IFileContract

Ayende Rahien
06/16/2008 03:06 PM by
Ayende Rahien

public class OldSvnBridgeFilesSpecification : IIgnoreFilesSpecification

{

public bool ShouldBeIgnored(string file)

{

    return Path.GetExtension(file) == ".svnbridge";

}

}

Julian Birch
06/16/2008 03:13 PM by
Julian Birch

Well, you still get to name the variable...

Predicate ignoreFilesSpecification = new OldSvnBridgeFilesSpecification().ShouldBeIgnored;

For instance.

But it really depends on how you're using the class, which I guess has always been the point.

Josh
06/16/2008 03:15 PM by
Josh

+1 for jonnii

Steve
06/16/2008 03:29 PM by
Steve

I like descriptive names, even if longer.

Mike
06/16/2008 03:33 PM by
Mike

I like prefer ending with 'Specification' for naming standard purposes...It helps too if I need to do a resharper Ctl+N with "*Specification" .

I would actually use IDisregardFilesSpecification or IIneligibleFilesSpecification naming.

Shaun
06/16/2008 03:39 PM by
Shaun

I like IFileFilter

Keith Elder
06/16/2008 04:01 PM by
Keith Elder

This reminds me of ICanLayEggs and IEggable! :)

http://deepfriedbytes.com/podcast/episode-2-interview-war-stories/

David Buksbaum
06/16/2008 04:55 PM by
David Buksbaum

+1 for the IFileFilter by jonnii

I think this makes it specific enough for the meaning to be understood, and general enough to promote reuse beyond the current context.

One other thing, is to possibly make this work in a chain, such that a series of IFileFilter's could be applied to jointly decide if the file should be ignored.

David

Shawn Neal
06/16/2008 04:59 PM by
Shawn Neal

Why do we love to talk about naming conventions/names so much?

Tobin Harris
06/16/2008 05:23 PM by
Tobin Harris

public interface Ignorant

{

bool Ignores(string test);

}

:-)

Raja Nadar
06/16/2008 06:25 PM by
Raja Nadar

how about IIgnoreFiles? [IVerbNoun since IAdjective (IIgnorable) doesn't sound good]

Alex Simkin
06/16/2008 07:56 PM by
Alex Simkin

IDisregarding or IDisregardable or IPayingNoAttentionTo

Avish
06/16/2008 08:00 PM by
Avish

If that interfaces is only used to recognize the SCM's meta-files (or whatever you call the .svnbridge folders), call it by that name and use it in that way:

IMetaFileLocator.IsMetaFile(string filename)

If it's supposed to be used to identify all files that should be ignored (during what? that's a key question), then I think the notion of an "excluder" -- that is, something that excludes files from general filespecs -- will work better:

IFileExcluder.ShouldExclude(string filename)

This suits the scenario where it makes sense to combine several of these, for example the default one that excludes meta-files, another one that excludes files based on svn:ignore properties, etc.

If there's no need to combine exclusions, then jonnii's FileFilter suggestion -- making the interface say which files should be processed, rather than which files should not be processed -- is slightly more intuitive IMO.

Alex Simkin
06/16/2008 08:15 PM by
Alex Simkin

One more:

IPicky with method Refuse

Kenneth LeFebvre
06/16/2008 08:45 PM by
Kenneth LeFebvre

For what it's worth, I like your idea of using the "I" as a first-person pronoun!

I tend to not use an "I" at all on my interfaces, rather ending my interface names with "Interface" or "Contract". But, I am also a big fan of active voice in my names (actually, in all of my writing, really) so if I used the Hungarian Eye naming convention for interfaces, I would probably go with your first proposal...

John Rayner
06/16/2008 10:37 PM by
John Rayner

I prefer method names to be verbs in the present tense. So I'd be similar to jonnii:

public interface IFileFilter

{

bool ShouldIgnore( string filename );

}

firefly
06/17/2008 01:21 AM by
firefly

IAmWhateverYouAndYourTeam can understand and agree on is good enough. I wouldn't stress over some name. Some XML documentation wouldn't hurt either.

Ken Egozi
06/17/2008 06:17 AM by
Ken Egozi

Started my comment here, moved it to my blog:

http://www.kenegozi.com/Blog/2008/06/17/naming-interfaces.aspx

In short - be specific. Either of Ayende's offers are good, IFileFilter is not my preference.

Sidar Ok
06/17/2008 09:00 AM by
Sidar Ok

ICanIgnoreFiles :)

Patrik
06/17/2008 01:18 PM by
Patrik

Depending on where this is used there's a good chance that I'd go with something like this:

public delegate bool FileFilter(string fileName);

If not that I'd go with the IFileFilter-interface.

Alessandro Riolo
06/17/2008 02:05 PM by
Alessandro Riolo

I agree with Ken about the name of the interface.

That said, in English "should" doesn't convey the meaning of absolute necessity. In example, as per RFT 2119, "SHOULD .. mean that there may exist valid reasons in particular circumstances to ignore a particular item, but the full implications must be understood and carefully weighed before choosing a different course.", while "MUST .. " ( or "REQUIRED" or "SHALL") ".. mean that the definition is an absolute requirement of the specification.", thus I would advice care also on the naming of the method. In layman's terms, is really ShouldBeIgnored or should be MustBeIgnored?.

Jeff Tucker
06/17/2008 06:35 PM by
Jeff Tucker

So should the chicken class implement ILayable or ICanLayEggs then?

Mats Helander
06/18/2008 05:02 AM by
Mats Helander

IFilesThatNeedToBeIgnoredRecognizer?

/Mats

Marc Wrobel
06/18/2008 06:07 AM by
Marc Wrobel

The first one, since IIgnoreFileSpecification doesn't talk to me very much.

Steve Freeman
06/18/2008 06:24 PM by
Steve Freeman

Surely it depends on the context in which the interface is to be used?

  • using the 'I' wart to refer to the object just seems wrong to me. We should do everything we can to ignore this unnecessary noise.

  • since it's a string, that's a "filename" or "pathname", not a "file".

Steve Campbell
06/19/2008 01:55 PM by
Steve Campbell

An interface with a single method is generally part of a strategy pattern. Given that, I would choose option 1, because it is indicative of what the strategy is for (recognizing files that need to be ignored). I can use the name of the option 1 interface in a conversation and its purpose will be clear.

Option 2 has a more concrete (implementation) feel to it (FileSpecification). It also uses "Ignore" as a verb, which in my interpretation is not what it does (it does not actually do the ignoring, only the recognition).

Ray
06/19/2008 08:25 PM by
Ray

IIgnorantFile :-)

Back on a serious note, I think IFileIgnore is best suggested name. Altho, I prefer Exclude instead of Ignore.

Kirill Osenkov
06/22/2008 12:48 AM by
Kirill Osenkov

I agree with Julian, a delegate can be nicer than an interface here. Just think of all the benefits you can get with lambdas.

If you don't like that Predicate is too generic (sic!), you can define your own:

public delegate bool FileFilter(string fileName);

Also, let us know what was your final decision. I'd be curious :)

Daniel Kolman
06/24/2008 01:09 PM by
Daniel Kolman

+1 for the IFileFilter by jonnii

But IMHO this discussion is great example of a fact that solving any problem without context is waste of time.

Ohad Aston
06/25/2008 07:33 AM by
Ohad Aston

The class that implement this interface should RECOGNIZE IF A FILE SHOULD BE IGNORED why calling it IFileFilter?

Call it IDoSomething and you solve the problem

Comments have been closed on this topic.