Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have VB.Net project, with a class with a couple of abstract (mustoverride) properties, that I am thinking about moving into an interface.

My question, is structurally how do I do this? Currently all of the classes that would be implementing this are derived from this base class, so it might make sense to put it in the same file. Or I could create a separate interface file and put it in the same directory as the base class. Another option, would be to create a separate directory for interfaces (of which the project currently has zero) and put the file the.

After writing this up, I'm strongly inclined towards the second option. I've looked around, but haven't found any guidance on this. What would be the best option and why?

share|improve this question
up vote 7 down vote accepted

Common guidance in .NET land, in most cases, is to have every class and interface in their own file. With a 1:1 correspondance between files and classes, navigation becomes easier. This argues against option #1.

Regarding the choice between #2 and #3, I would argue for the former, with some caveats. I don't think you should have a folder for interfaces, but rather a folder structure based on the domain model. Group your files by subject, not into classes vs. interfaces.

The main caveat, though, if that once your application gets bigger, it might get split off into different projects, and not all projects can reference the project where the interface might be defined. In this case, we'll often create a separate project for contracts and interfaces, which is then referenced by other projects.

share|improve this answer

I would group all my classes and interfaces in a separate folder. Everything should be grouped by functionality and not by whether it is a base class, an interface or whatever.

What would happen if you had a complex design pattern, would you subdivide the interfaces in separate folders?

share|improve this answer
+1 for grouping by functionality. MS got that absolutely wrong with the way they set up many template projects. – Marjan Venema Jul 6 '13 at 18:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.