How to organize interfaces / classes / implementations in a project

I found some questions about how to organize projects (namespace, one class for each file, etc.), but in a more specific note, how do you organize “things” that are very closely related?

I usually end up:

  • interface IMyStuff
  • The base (sometimes abstract) class that provides the base skeleton for this interface:BaseMyStuff
  • implementation classes MyStuffWithBellsAndWhistles ,MyStuffWithChocolateFlavours

It seems like they should be in the same namespace, but it seems that my folders are starting to get a little overloaded if I put all these files in the same folder (this is not really a real problem, but it is weird).

Is it possible to define both an interface and a base class in a single file?

Or would it be convenient to group these things in subfolders, but in the same namespace ? eg:

-MyNamespace
 |-Interfaces
   | -IMyStuff
   | -IMyOtherStuff
 |-BaseClasses
   | -BaseMyStuff
   | -BaseMyOtherStuff
 |-Implementation
   | -MyStuffWithAwesomeBehaviour
   | -MyStuffWithGreatUsefulness
   | -MyOtherStuffSoNeatYouWillCry

What are the “best practices” for this kind of organization?

+5
source share
1 answer

, , . unit test , , . , .

0

All Articles