Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

namespace naming conventions

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?

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 ?

like image 214
Razor Avatar asked May 28 '09 02:05

Razor


People also ask

What is the name of namespace?

A namespace in computer science (sometimes also called a name scope) is an abstract container or environment created to hold a logical grouping of unique identifiers or symbols (i.e. names). An identifier defined in a namespace is associated only with that namespace.

What is naming convention and example?

A naming convention can include capitalizing an entire word to denote a constant or static variable (which is commonly done in Flash programming), or it could be a simple character limit in a coding language (such as SQL). Naming conventions have functional as well as organizational qualities.

What is naming convention in SAP?

Conventions for Object Types. Class and interface names in the class library belong to the same namespace as data elements, tables, structures, and types. They are maintained centrally in the table TADIR. Class in the class library.


2 Answers

From the Namespace Naming Guidelines:

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][.Design]

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.

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

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.

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

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

like image 57
coobird Avatar answered Oct 07 '22 04:10

coobird


Also have a look at following MSDN article for guidelines about naming Namespaces

Names of Namespaces

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

The general format for a namespace name is as follows:

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

For example, Microsoft.WindowsMobile.DirectX.

like image 26
akjoshi Avatar answered Oct 07 '22 06:10

akjoshi