David Osborne
David Osborne

Reputation: 6801

What is best practice regarding Interface organisation Visual Studio projects?

Single file for all interfaces or one file per interface definition?

Balena & Dimauro's of book of 'Pratical Guidelines' advocates a single file called Interfaces.vb/cs to hold all interface definitions. Their aim is to minimise the proliferation of small files, where each holds a single interface definition.

I can see benefits to both approaches. Does anyone have any strong views or experience that strongly supports one approach?

Upvotes: 2

Views: 336

Answers (3)

user2655145
user2655145

Reputation:

In Visual Studio you can have one file with multiple classes or interfaces. In Solution explorer the file would expand much like a tree view, to expose all classes/Interfaces in the file.

My preference would be to have all Interfaces under the same namespace in a single file. In other words group them by NameSpace in a single file.

Upvotes: 0

Habib
Habib

Reputation: 223282

I would say, its better to have them in a separate file specially if your solution is in source control. If you have multiple check outs disabled in your source control then only one developer can work on one file/interface. Also you can compare what has been checked in against each interface, instead of looking at the difference of files.
If you have a interface which is only implemented in one class, then I would rather have both of them in a same file.

Upvotes: 3

walther
walther

Reputation: 13600

Well you said it yourself - each approach has its pros and cons. However, to make a decision easier, I'd say this:

If you develop only a small application (let's say max 10 interfaces), you can use single file if you want and be happy about it.

However, if you develop a larger application that will need to scale over time, use multiple files. It's certainly easier to maintain that way.

Well at least this is my opinion. :)

Upvotes: 3

Related Questions