how do you organize your namespaces?

…衆ロ難τιáo~ 提交于 2020-01-13 10:12:09

问题


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.


回答1:


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



回答2:


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.




回答3:


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.




回答4:


I follow the Java / python ideal that namespaces should follow the directory structure.



来源:https://stackoverflow.com/questions/123114/how-do-you-organize-your-namespaces

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!