Ayende @ Rahien

Hi!
My name is Ayende Rahien
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:

ayende@ayende.com

+972 52-548-6969

, @ Q c

Posts: 5,949 | Comments: 44,548

filter by tags archive

Comments

Peter Ritchie

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

Guy
Guy

How about "IIgnorable"?

Jack

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

jonnii

public interface IFileFilter{

bool ShouldProcess(bool file);

}

??

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

What about 'public interface IIgnoredFilesRecognizer'?

Rik Hemsley

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

Tuna Toksoz

Both sounded weird to me.

IIgnorableFileSpecifier? maybe?

Mike D

IFileFilter gets my vote

Julian Birch

I agree naming is important, but how about Predicate?

Ayende Rahien

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

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

IFileFilter or IFileContract

Ayende Rahien

public class OldSvnBridgeFilesSpecification : IIgnoreFilesSpecification

{

public bool ShouldBeIgnored(string file)

{

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

}

}

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

+1 for jonnii

Steve

I like descriptive names, even if longer.

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

I like IFileFilter

Keith Elder

This reminds me of ICanLayEggs and IEggable! :)

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

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

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

Tobin Harris

public interface Ignorant

{

bool Ignores(string test);

}

:-)

Raja Nadar

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

Alex Simkin

IDisregarding or IDisregardable or IPayingNoAttentionTo

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

One more:

IPicky with method Refuse

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

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

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

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

ICanIgnoreFiles :)

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

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

So should the chicken class implement ILayable or ICanLayEggs then?

Mats Helander

IFilesThatNeedToBeIgnoredRecognizer?

/Mats

Marc Wrobel

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

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

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
Ray

IIgnorantFile :-)

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

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

+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

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

Comment preview

Comments have been closed on this topic.

FUTURE POSTS

No future posts left, oh my!

RECENT SERIES

  1. The RavenDB Comic Strip (3):
    28 May 2015 - Part III – High availability & sleeping soundly
  2. Special Offer (2):
    27 May 2015 - 29% discount for all our products
  3. RavenDB Sharding (3):
    22 May 2015 - Adding a new shard to an existing cluster, splitting the shard
  4. Challenge (45):
    28 Apr 2015 - What is the meaning of this change?
  5. Interview question (2):
    30 Mar 2015 - fix the index
View all series

RECENT COMMENTS

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats