473,395 Members | 2,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Namespace Best Practices

Can someone point me to some information on namespace best practices?
Questions I have are as follows:

1) Should I use .NET namespaces or URL, URI and URN's? Ie
mycompany.mydivision.myapp vs http://www.mycompany.com/division/app?
2) Should I use namespace prefixes? I thought I read something using
prefixes is a bad idea?
3) etc.

Thanks in advance.
Steve
Nov 23 '05 #1
2 3455
"steve" <st***@discussions.microsoft.com> wrote in message news:FA**********************************@microsof t.com...
Can someone point me to some information on namespace best practices? : : 1) Should I use .NET namespaces or URL, URI and URN's? Ie
mycompany.mydivision.myapp vs http://www.mycompany.com/division/app?
You should use CLR (Common Language Runtime) namespaces like
MyCompany.MyApp in your CLS (Common Language Spec) or .NET
programming language source files. You should use URI's for XML
namespaces (URL, URN, take your pick, it's not like the location you
get by dereferencing a URL needs to exist). If you interchange these
you will get errors.

While your URL doesn't need to physically exist, make sure you own
the domain name in it, otherwise somebody else will buy it for $5. If
you don't own a URL, or it's only for demonstration purposes, then
you can use a demo URL like www.example.com or www.tempuri.org
which have been scarfed up as a community service for that purpose.

: : 2) Should I use namespace prefixes? I thought I read something using
prefixes is a bad idea?


Yes, use namespace prefixes. It's the only way to refer to entities from
two different namespaces simultaneously. You'll need to do this a lot
when working with SOAP and WS-*, there's no avoiding it.

However, don't think your namespace prefixes are special. It's not the
namespace prefix that matters, it is the namespace URI behind it. If
you have two prefixes that are different (ns1 and ns2), but you declare
them w/ the same, identical namespace URI (http://www.example.com),
then ns1:elem and ns2:elem have the same qualified name (QName,
think of it as http://www.example.com:elem for both of them).
Derek Harmon
Nov 23 '05 #2
Derek,
Thanks for the reply that helps. One more questions if you don't mind.

1) Are there any guidelines on when I should use a URL vs a URN? I see on
w3c's website they have samples like <book xmlns='urn:loc.gov.books..... and
then in the same document it uses something like <Beers
xmlns="http://xxxx.xx.xx".
"Derek Harmon" wrote:
"steve" <st***@discussions.microsoft.com> wrote in message news:FA**********************************@microsof t.com...
Can someone point me to some information on namespace best practices?

: :
1) Should I use .NET namespaces or URL, URI and URN's? Ie
mycompany.mydivision.myapp vs http://www.mycompany.com/division/app?


You should use CLR (Common Language Runtime) namespaces like
MyCompany.MyApp in your CLS (Common Language Spec) or .NET
programming language source files. You should use URI's for XML
namespaces (URL, URN, take your pick, it's not like the location you
get by dereferencing a URL needs to exist). If you interchange these
you will get errors.

While your URL doesn't need to physically exist, make sure you own
the domain name in it, otherwise somebody else will buy it for $5. If
you don't own a URL, or it's only for demonstration purposes, then
you can use a demo URL like www.example.com or www.tempuri.org
which have been scarfed up as a community service for that purpose.

: :
2) Should I use namespace prefixes? I thought I read something using
prefixes is a bad idea?


Yes, use namespace prefixes. It's the only way to refer to entities from
two different namespaces simultaneously. You'll need to do this a lot
when working with SOAP and WS-*, there's no avoiding it.

However, don't think your namespace prefixes are special. It's not the
namespace prefix that matters, it is the namespace URI behind it. If
you have two prefixes that are different (ns1 and ns2), but you declare
them w/ the same, identical namespace URI (http://www.example.com),
then ns1:elem and ns2:elem have the same qualified name (QName,
think of it as http://www.example.com:elem for both of them).
Derek Harmon

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: byrocat | last post by:
I'm chasing after a documetn that was available on one of the Microsoft websites that was titled somethign like "MS SQL Server Best Practices" and detailed a nyumber of best practices about...
5
by: Dave Slinn | last post by:
Any advice on how to organize my core class library project into sub-namespaces? What are the general rules of thumb regarding cross-namespace references? Can I have a class in namespace A have a...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
1
by: Bakunin | last post by:
Hi, I may be doing something dumb but.......I have been using the data access ent lib to do the HOL's. All is well. However I now want to add the data access functionality to my BTS2004 project,...
13
by: john doe | last post by:
A quick question, about so-called 'best practices', I'm interested in which of A/B of the two examples people would choose, and why. public enum MyEnum { Option1 = 0, Option2 = 1, Option3 =...
14
by: Jon Rea | last post by:
I am currently cleaning up an application which was origainlly hashed together with speed of coding in mind and therefore contains quite a few "hacky" shortcuts. As part of this "revamping"...
12
by: bgeneto | last post by:
I know that it's a very basic question, but I can't figure out or find an answer to why do we have to specify a namespace, like this #include<string> using namespace std; when using the...
3
by: John Dalberg | last post by:
I am looking for an ASP.NET application on CodePlex which exemplifies best practices for the following: - Use of interfaces - Seperation of the UI, business and data tiers - Data Tier that uses...
2
by: Max2006 | last post by:
Hi, Is there any MSDN or industry standard article that recommends best practices for namespace naming and assembly names? I like to have assembly names same as the base namespace name within...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.