命名空间的命名约定 [英] namespace naming conventions

查看:198
本文介绍了命名空间的命名约定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于那些你在那里编写可重用的组件,你认为什么是最好的做法,如果你扩展.NET框架的功能?

For those of you out there writing reusable components, what do you consider to be best practice if you're extending the functionality of the .NET framework?

例如,我创建的那一刻一个POP3库作为一个不以.NET存在。难道我创建一个自定义命名空间还是我使用 System.Net.Mail

For example, I'm creating a Pop3 library at the moment as one doesn't exist in .NET. Do I create a custom namespace or do I use System.Net.Mail ?

推荐答案

命名空间命名指南

命名命名空间的一般规则   是用公司名称,后跟   的技术名称和任选的   功能和设计如下。复制   code

The general rule for naming namespaces is to use the company name followed by the technology name and optionally the feature and design as follows. Copy Code

CompanyName.TechnologyName [.Feature] [设计]

通常这是一个非常不好的做法,开始包括东西塞进一个框架或库的默认命名空间。这可能会导致混乱的一个新的命名空间是否是现有库,是被分给大家一个框架的一部分,或者是被加入别人的自定义框架的组成部分的组成部分条款。

Generally it's a really bad practice to start including things into the default namespace of a framework or library. This can cause confusion in terms of whether a new namespace is part of the existing library that is part of a framework that is distributed to everyone, or is part of a custom framework that was added by someone else.

此外,命名规则试图避免名称空间冲突依靠其独特的标识符,如公司名称。这也减少了新库的源方面的混乱和问题。

Also, the naming convention tries to avoid namespace collisions by having unique identifiers such as CompanyName. It also reduces any confusion and issues in terms of the source of the new library.

此不仅是微软的事,但在Java为好。在Java中的命名空间,所谓的套餐有以下约定

This is not only a Microsoft thing, but in the Java as well. Namespaces in Java, called "packages" has the following convention:

独特的包名的preFIX是   总是写在全部小写的ASCII   字母和应该是一个   顶级域名,目前玉米,   EDU,GOV,MIL,净,组织,或一个   英语两个字母codeS标识   国家在ISO标准规定   3166,1981年。

The prefix of a unique package name is always written in all-lowercase ASCII letters and should be one of the top-level domain names, currently com, edu, gov, mil, net, org, or one of the English two-letter codes identifying countries as specified in ISO Standard 3166, 1981.

后续的包组件   根据一个命名变化   组织自己的内部命名   约定。这样的约定可能   指定某些目录名称   组件是子公司,部门,   工程,机械,或登录名。

Subsequent components of the package name vary according to an organization's own internal naming conventions. Such conventions might specify that certain directory name components be division, department, project, machine, or login names.

所以,如果我有一个超级真棒的软件,它可能是在 net.coobird.superawesomesoftware 包。

So, if I had a super awesome piece of software, it may be in the net.coobird.superawesomesoftware package.

和使用包含默认 Java包名称。的javax。 COM 。孙。包是一大禁忌。

And using package names that contain the default java., javax., com.sun. packages are a big no-no.

这篇关于命名空间的命名约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆