Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I Use The Back Tick Convention On An Interface?

When you have a generic class, with different type parameter overloads it seems generally accepted that you use the back-tick syntax in the file name:

MyType.cs
MyType`1.cs
MyType`2.cs

Is this the same for an interface? For example:

IRepository.cs
IRepository`2.cs

Where you have these corresponding type parameters:

public interface IRepository {

and

public interface IRepository<T, in TId> {
like image 944
Fenton Avatar asked Dec 07 '22 12:12

Fenton


1 Answers

File conventions are just a personal/team preference. You could do this, if you so choose.

I, personally, tend to put these in the same file. If I'm looking for IRepository, I would assume that any and all IRepository interfaces are all similar, and all represent a "repository", so I'd just look for them in the same place. This would avoid needing to figure out which of the `2, etc, files to search through. For me, "IRepository`5.cs" is not more readable or discoverable than finding these all in one file.

like image 81
Reed Copsey Avatar answered Dec 10 '22 01:12

Reed Copsey