The situation is as follows.
public interface IFoo { } public abstract class FooBase : IFoo { }
Now I need a collection of IFoo with some additional methods.
public class IFooCollection : List<IFoo> { public void UsefullMethod() { } }
The problem is that IFooCollection looks like an interface while it is a class. The options are the following.
- Keep it
IFooCollection– I don’t like this because it looks like an interface. - Name it
FooCollection– I don’t like this because it is not a collection of foos. - Turn it into
FooBaseCollectionbecause all implementations ofIFooderive fromFooBase– I don’t like this because this might not be true forever. - Don’t create the class at all but provide extension methods for
IList<IFoo>because there are only a hand full methods – I don’t like this because changing the code because you cannot find a name for a class … yes, that is nasty. - Something I did not think about or forgot to write it down – I hope I will like it!
So what would you do? Is there a naming convention I missed? We are basicaly using this Microsoft .NET Library Standards.
UPDATE
The code will not become widespread – it is just inside a GUI tool to put some data into a server. So I don’t care about using the methods with other collections or overlooking the methods.
I like
FooCollectionyou have a collection of the conceptual object ‘Foo’ even if there is not an actualFooclass or interface. This is in keeping withIFoois an interface of a ‘Foo’ even if there is noFooclass.SpecialFoowould be a special kind of ‘Foo’ even though there is noFooclass.I definitely agree that
IFooCollectionis wrong because of the implied interface.