So I have logical entities (person, country, etc.), GUI elements / controls, data and navigation controllers / managers, then things like quad-trees and timers, and I always struggle with cleanly separating these things into logical namespaces.
I usually have something like this:
- Leviathan.GUI.Controls
- Leviathan.GUI.Views
- Leviathan.Entities
- Leviathan.Controllers (data and other stuff)
- Leviathan.Helpers (trees and other stuff)
Are there any good guides on this? I need to stop this mess.
For applications
Company.Product.Tier.Sub.Sub
where I like to get Tier from Model, View, Controller or other established names (Data)
But for our controls, we end up with
Company.Product.LogicalFeatureGrouping
or
Company.Product.Addon
sometimes it's
Company.Product.LogicalFeatureGrouping.Addon
Try to avoid the "and other stuff" or "misc." categories, If you are putting things in these categories you are failing to really organize them at all.
I usually create a namespace for every single tiers, like UI, business logic and database. It forces me to separate the tiers. I create other namespaces inside them according to system components.
I follow the Java / python ideal that namespaces should follow the directory structure.
来源:https://stackoverflow.com/questions/123114/how-do-you-organize-your-namespaces