I understand that naming matters, so...

Which should I use?

This:

image

Or this:

image

Print | posted on Monday, June 16, 2008 4:52 PM

Feedback


Gravatar

# re: I understand that naming matters, so... 6/16/2008 5:02 PM Peter Ritchie

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


Gravatar

# re: I understand that naming matters, so... 6/16/2008 5:35 PM Guy

How about "IIgnorable"?


Gravatar

# re: I understand that naming matters, so... 6/16/2008 5:35 PM Jack

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


Gravatar

# re: I understand that naming matters, so... 6/16/2008 5:35 PM jonnii

public interface IFileFilter{
bool ShouldProcess(bool file);
}

??


Gravatar

# re: I understand that naming matters, so... 6/16/2008 5:36 PM 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.


Gravatar

# re: I understand that naming matters, so... 6/16/2008 5:37 PM Drakiula

What about 'public interface IIgnoredFilesRecognizer'?


Gravatar

# re: I understand that naming matters, so... 6/16/2008 5:37 PM Rik Hemsley

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


Gravatar

# re: I understand that naming matters, so... 6/16/2008 5:38 PM Tuna Toksoz

Both sounded weird to me.
IIgnorableFileSpecifier? maybe?


Gravatar

# re: I understand that naming matters, so... 6/16/2008 5:43 PM Mike D

IFileFilter gets my vote


Gravatar

# re: I understand that naming matters, so... 6/16/2008 5:48 PM Julian Birch

I agree naming is important, but how about Predicate<string>?


Gravatar

# re: I understand that naming matters, so... 6/16/2008 5:52 PM Ayende Rahien

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


Gravatar

# re: I understand that naming matters, so... 6/16/2008 6:02 PM 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?


Gravatar

# re: I understand that naming matters, so... 6/16/2008 6:03 PM Juliano Nunes

IFileFilter or IFileContract


Gravatar

# re: I understand that naming matters, so... 6/16/2008 6:06 PM Ayende Rahien

public class OldSvnBridgeFilesSpecification : IIgnoreFilesSpecification
{
public bool ShouldBeIgnored(string file)
{
return Path.GetExtension(file) == ".svnbridge";
}
}


Gravatar

# re: I understand that naming matters, so... 6/16/2008 6:13 PM Julian Birch

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

Predicate<string> 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.


Gravatar

# re: I understand that naming matters, so... 6/16/2008 6:15 PM Josh

+1 for jonnii


Gravatar

# re: I understand that naming matters, so... 6/16/2008 6:29 PM Steve

I like descriptive names, even if longer.


Gravatar

# re: I understand that naming matters, so... 6/16/2008 6:33 PM 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.


Gravatar

# re: I understand that naming matters, so... 6/16/2008 6:39 PM Shaun

I like IFileFilter


Gravatar

# re: I understand that naming matters, so... 6/16/2008 7:01 PM Keith Elder

This reminds me of ICanLayEggs and IEggable! :)

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


Gravatar

# re: I understand that naming matters, so... 6/16/2008 7:55 PM 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


Gravatar

# re: I understand that naming matters, so... 6/16/2008 7:59 PM Shawn Neal

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


Gravatar

# re: I understand that naming matters, so... 6/16/2008 8:23 PM Tobin Harris

public interface Ignorant
{
bool Ignores(string test);
}

:-)


Gravatar

# re: I understand that naming matters, so... 6/16/2008 9:25 PM Raja Nadar

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


Gravatar

# re: I understand that naming matters, so... 6/16/2008 10:56 PM Alex Simkin

IDisregarding<T> or IDisregardable<T> or IPayingNoAttentionTo<T>


Gravatar

# re: I understand that naming matters, so... 6/16/2008 11:00 PM 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.


Gravatar

# re: I understand that naming matters, so... 6/16/2008 11:15 PM Alex Simkin

One more:

IPicky with method Refuse


Gravatar

# I like it 6/16/2008 11:45 PM 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...


Gravatar

# re: I understand that naming matters, so... 6/17/2008 1:37 AM 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 );
}


Gravatar

# re: I understand that naming matters, so... 6/17/2008 4:21 AM firefly

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


Gravatar

# re: I understand that naming matters, so... 6/17/2008 9:17 AM 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.


Gravatar

# re: I understand that naming matters, so... 6/17/2008 12:00 PM Sidar Ok

ICanIgnoreFiles :)


Gravatar

# re: I understand that naming matters, so... 6/17/2008 4:18 PM 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.


Gravatar

# re: I understand that naming matters, so... 6/17/2008 5:05 PM 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?.


Gravatar

# re: I understand that naming matters, so... 6/17/2008 9:35 PM Jeff Tucker

So should the chicken class implement ILayable or ICanLayEggs then?


Gravatar

# re: I understand that naming matters, so... 6/18/2008 8:02 AM Mats Helander

IFilesThatNeedToBeIgnoredRecognizer?

/Mats


Gravatar

# re: I understand that naming matters, so... 6/18/2008 9:07 AM Marc Wrobel

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


Gravatar

# re: I understand that naming matters, so... 6/18/2008 9:24 PM 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".


Gravatar

# re: I understand that naming matters, so... 6/19/2008 4:46 PM Benny Thomas


IFileIgnoranceRule


Gravatar

# re: I understand that naming matters, so... 6/19/2008 4:55 PM 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).


Gravatar

# re: I understand that naming matters, so... 6/19/2008 11:25 PM Ray

IIgnorantFile :-)


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


Gravatar

# re: I understand that naming matters, so... 6/22/2008 3:48 AM 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<T> 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 :)


Gravatar

# re: I understand that naming matters, so... 6/24/2008 4:09 PM 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.


Gravatar

# re: I understand that naming matters, so... 6/25/2008 10:33 AM 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.