开发者

What is the correct file name for the interface "IRepository<T>"

开发者 https://www.devze.com 2022-12-15 14:36 出处:网络
Just curious what people would n开发者_开发知识库ame the file that contains the generic interface IRepository<T>.

Just curious what people would n开发者_开发知识库ame 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.


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


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


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


I would go with IRepository.cs

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


Maybe this is helpful.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号