How do you come up with names for your namespaces?

不羁岁月 提交于 2019-12-10 03:54:11

问题


I'll preface this by saying that I usually work in C#/.Net.

Normally, I use a naming scheme that puts common, reusable components into a namespace that reflects our organization and project-specific components into a namespace tied to the project. One of the reasons I do this is that I sometimes share my components with others outside my department, but within the organization. Project-specific namespaces are typically prefaced with the name or abbreviation of the department. When I reuse code between projects, I typically migrate it into one of the organization-based namespaces.

For example:

UIOWA.DirectoryServices contains classes that deal with the specific implementation of our Active Directory.

UIOWA.Calendar contains classes that deal with the University's master calendar.

LST.Inventory.Datalayer holds the classes implementing the data layer of the Learning Spaces Technology group inventory application.

I'm embarking on a project now for an entity that has a fuzzier connection to the Unviersity (a student group that runs a charity event) that has the potential to be sold outside of our University and, thus, it doesn't really fit into my normal naming conventions, i.e., the department is only the first customer of potentially many that might use the project.

My inclination is to go the organization naming route and create an "organizational project" name space for this application. I'd like to hear how others handle this and any advice you might have.

Thanks.

See also this related question about namespace organization.

EDIT

I ended up creating the org/project namespace UIOWA.MasterEvent and deriving further namespaces from there. Still interested in other opinions for future projects.


回答1:


My department got his name changed thrice in the last five years, so we're all glad that someone decided against using namespaces with organisational names...

Our namespaces are organised by project names. Reusable stuff is put into the Toolbox namespace. Perhaps a bit crude, but it works quite well so far.




回答2:


I'm a .NET developer, and I always use the organisational project namespace (com.bolidian.projectspace) because it guarantees uniqueness.




回答3:


I use the organisation, followed by the product eg Acme.Crm. When grouping classes together in a subnamespace always use a plural or action so that it cant clash with a class. eg

  • Acme.Crm.Letters
  • Acme.Crm.Invoicing

I follow Microsoft's convention by not capitalising acronyms eg Crm instead of CRM, Sql instead of SQL - but that's more a personal preference.



来源:https://stackoverflow.com/questions/240033/how-do-you-come-up-with-names-for-your-namespaces

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