views:

243

answers:

6

Just curious what people would name the file that contains the generic interface IRepository<T>.

IRepositoryT.cs?

Update

One minor point to add. Normally, when you change the name of a class file, Visual Studio asks if you want to do a rename on the class as well. In the case of IRepository<T>, no matter what I name the file (IRepository or IRepositoryT or IRepositoryOfT, etc.), the link between the file name and the class name is never established.

A: 

I would go with IRepository.cs

I don't think the fact that the type is generic should make a difference.

Jaco Pretorius
+1  A: 

Depends if you have IRepository also, and you like to keep different interface definitions in different files.

If so, IRepositoryT.cs, or else IRepository.cs

And I'd put it in a folder named Interfaces, but that's me, and I'm a bit OCD in this area

PostMan
I would say "IRepository.cs" and "IRepositoryGeneric.cs" instead. Maybe even include both in the same file and name it "IRepository.cs"
Sergey
Yeah, I'd go with the same file idea, depending on the size of the interface. Also IRepositoryGeneric.cs is a much better idea! Thanks!
PostMan
+1  A: 

Maybe this is helpful.

mkus
Oo, I like that...`IRepositoryOfT`
DanM
+1  A: 

I would name it as I say it: IRepositoryOfT.cs

Gordon Mackie JoanMiro
+1 I like this answer.
DanM
+4  A: 

Personally I would use IRepository.cs. The only difference is when I, for a generic class, also has a nongeneric version of the same, either for compatibility with legacy code, or to provide static methods available to any T.

In this case I would name them:

  • IRepository.NonGeneric.cs
  • IRepository.cs
Lasse V. Karlsen
A: 

I usually just use IRepository.cs. And unless they are very big classes, I tend to keep IRepository and IRepository<T> in the same file. Usually with the non-generic on top, since the generic one usually extends the non-generic one.

When I have split it into two files, I have usually used IRepository(Of T).cs, but the suggestion from others here with IRepositoryOfT.cs sure is a good one. Might use that one :p

Svish