5

The standard naming convention in the Java world is to name packages, classes and methods according to:

com.domainname.productname (package)
com.domainname.productname.ClassName (class)
com.domainname.productname.ClassName.isUpperCase(String str) (method)

What is the C#/.NET standard naming convention for the above cases?

knorv
  • 49,059
  • 74
  • 210
  • 294

2 Answers2

7

AKU's answer should help you out:

.NET namespaces

He links to Microsoft's guidelines:

http://msdn.microsoft.com/en-us/library/893ke618(VS.71).aspx

You should consider reading the the rest of the guidelines starting here:

http://msdn.microsoft.com/en-us/library/czefa0ke(VS.71).aspx

The remainder of the post is also very informative:

.NET namespaces

In your case you would go with:

CompanyName.ProductName
CompanyName.ProductName.ClassName
CompanyName.ClassName.IsUpperCase(string str)

The .NET guidelines don't follow the Java style of using reversed FQ domain names to specify namespaces, and I've yet to see a commercial component such as Telerik or Infragistics for example follow anything other the guidelines than the MS ones.

Community
  • 1
  • 1
Kev
  • 118,037
  • 53
  • 300
  • 385
3

It is rare to see "com." in C# or .NET:

DomainName.ProductName (namespace)
DomainName.ProductName.ClassName (class)
DomainName.ProductName.ClassName.IsUpperCase(String str) (method)

See the .NET Library Design Guidelines from Microsoft for the full scoop (this is really a .NET question more than a C# question).

Joe Erickson
  • 7,077
  • 1
  • 31
  • 31
  • I've wondered why so many Java packages start with `com.`. Since almost all company domain names end in `.com`, it seems redundant. – David R Tribble Dec 11 '09 at 22:08
  • As far as I can remember - and I started using Java in 1995 or 1996 - it is simply the convention that Sun followed and everybody else followed along. – Joe Erickson Dec 12 '09 at 22:17
  • I've actually seen a lot of `org.*` and some `edu.*` packages. It fits with Java's "assume and write for the most unusual situation" inclinations. – ehdv Mar 02 '10 at 15:39
  • 2
    @DavidRTribble, the convention comes from trying to differentiate company.com from company.org, etc. Java took the position that no domain name would indicate more than one company, so it was a fairly explicit, ubiquitous and universal "identifier". It's actually a cleaner technique in my opinion that "CompanyName" only in there is no guarantee that a two similarly named companies won't accidentally name something the same. For instance, before the World Wrestling Federation lost "WWF" to the World Wildlife Fund, they might both chose WWF.ProductName. If of course they were into software.:) –  Jan 25 '15 at 20:15