The project I'm working on has quite a few classes. These classes can be grouped in two different ways. I'm trying to decide which grouping is best as for namespacing. Currently I a set of user facing classes that look like:
JamJar
HoneyJar
PeanutButterJar
- etc...
These are all similar in that they all inherit from SpreadableJar
, each spreadable prefix could be considered a 'topic' within in the project.
I also have a set of objects relating to these topics, each topic usually has a set of constant definitions and message classes associated with it so I end up with a bundle of files such as:
JamDefinitions
PeanutButterSpreadMessage
HoneyDefinitions
JamRemoveMessage
- etc...
I can think of two ways to organise these files:
By Topic First level is namespace, second is class/file name.
- Jam
- Jar
- Definitions
- RemoveMessage
- etc...
- Honey
- Jar
- Definitions
- etc...
- PeanutButter
- Jar
- Definitions
- SpreadMessage
- etc...
- Jam
This seems tidy (removes duplicated names) and is useful to the user of the library but means that all the Jar files look the same in the project structure, and each Jar class no longer has a descriptive name. It also means that related objects are grouped together so they will not need to scope into each others namespaces
By Purpose
- Jars
- JamJar
- HoneyJar
- PeanutButterJar
- Definitions
- JamDefinitions
- HoneyDefinitions
- PeanutButterDefinitions
- Messages
- JamRemoveMessage
- etc...
- Jars
This way is clear to the user if they know that they need to use Jars (the rest of the objects won't be needed by external users) and it separates the large number of messages and the separate definitions files from the main functionality, but now the Jars will need to scope into the other namespaces for their own definitions and messages and the file naming becomes more awkward. The 'Jar' from JamJar can't really be removed because the class is not just 'Jam'.
What is the best approach here? Am I missing some obvious solution or error in my structure?