FUTURE POSTS
- Partial writes, IO_Uring and safety - about one day from now
- Configuration values & Escape hatches - 5 days from now
- What happens when a sparse file allocation fails? - 7 days from now
- NTFS has an emergency stash of disk space - 9 days from now
- Challenge: Giving file system developer ulcer - 12 days from now
And 4 more posts are pending...
There are posts all the way to Feb 17, 2025
Comments
I would avoid IIgnoreFilesSpecification to avoid confusing it with a Specification pattern implementation.
How about "IIgnorable"?
I'd go with the first one, seeing the 2 I's next to each other gives me a headache. :)
public interface IFileFilter{
bool ShouldProcess(bool file);
}
??
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.
What about 'public interface IIgnoredFilesRecognizer'?
Oh and I agree with jonnii - that's a much better name.
Both sounded weird to me.
IIgnorableFileSpecifier? maybe?
IFileFilter gets my vote
I agree naming is important, but how about Predicate<string>?
Predicate is useless, it doesn't tell me what it does.
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?
IFileFilter or IFileContract
public class OldSvnBridgeFilesSpecification : IIgnoreFilesSpecification
{
}
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.
+1 for jonnii
I like descriptive names, even if longer.
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.
I like IFileFilter
This reminds me of ICanLayEggs and IEggable! :)
http://deepfriedbytes.com/podcast/episode-2-interview-war-stories/
+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
Why do we love to talk about naming conventions/names so much?
public interface Ignorant
{
bool Ignores(string test);
}
:-)
how about IIgnoreFiles? [IVerbNoun since IAdjective (IIgnorable) doesn't sound good]
IDisregarding<T> or IDisregardable<T> or IPayingNoAttentionTo<T>
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.
One more:
IPicky with method Refuse
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...
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 );
}
IAmWhateverYouAndYourTeam can understand and agree on is good enough. I wouldn't stress over some name. Some XML documentation wouldn't hurt either.
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.
ICanIgnoreFiles :)
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.
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?.
So should the chicken class implement ILayable or ICanLayEggs then?
IFilesThatNeedToBeIgnoredRecognizer?
/Mats
The first one, since IIgnoreFileSpecification doesn't talk to me very much.
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".
IFileIgnoranceRule
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).
IIgnorantFile :-)
Back on a serious note, I think IFileIgnore is best suggested name. Altho, I prefer Exclude instead of Ignore.
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 :)
+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.
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