Naming conventions

For those of you who write reusable components there, what do you think is best practice if you extend the functionality of the .NET platform?

For example, I am creating the Pop3 library at the moment, because it does not exist in .NET. Create a custom namespace or use System.Net.Mail ?

+43
c # namespaces
May 28 '09 at 2:07 a.m.
source share
2 answers

From the Namespace Naming Rule :

A general rule for namespace names is to use the company name, followed by the name of the technology and possibly the functions and design as follows. Copy Code

CompanyName.TechnologyName[.Feature][.Design]

This is usually a very bad practice to start including things in the default namespace for an infrastructure or library. This can be confusing as to whether the new namespace is part of an existing library, which is part of a structure that is shared by everyone, or is part of a custom structure added by someone else.

In addition, the naming convention attempts to avoid namespace conflicts by using unique identifiers such as CompanyName . It also reduces any confusion and problems in terms of the source of the new library.

This is not only Microsoft, but also Java. Java namespaces called packages have the following convention :

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

The subsequent components of the package name vary depending on the organization of your own internal naming conventions. Such conventions may indicate that a particular catalog name component is a department, department, project name, machine name, or username.

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

And using the names of packages that contain java. default packages java. , javax. , com.sun. are great, no no.

+57
May 28 '09 at 2:14
source share

Also check out the following MSDN article for namespace naming guidelines.

Namespace Names

The name chosen for the namespace should indicate the functionality performed, available by type in the namespace. For example, the System.Net.Sockets namespace contains types that allow developers to use sockets to communicate over networks.

The general namespace name format is as follows:

<Company>.(<Product>|<Technology>)[.<Feature>][.<Subnamespace>]

For example, Microsoft.WindowsMobile.DirectX .

+15
Jan 07
source share



All Articles