?
Solved

Namespace concept

Posted on 2007-11-14
2
Medium Priority
?
655 Views
Last Modified: 2013-11-07
In asp.net, what is the concept of the Namespace?

I mean, I am looking at a Custom MembershipUser, at the top it has a Namespace of say, MyNameSpace....

within this MembershipUser, it implements a custom ObjectBase class, which also has the namespace MyNameSpace.

Then in this example I'm looking at, there are a couple of other custom classes and they have a namespace of, for example:

MyNameSpace.Stuff

Why do you create this "Stuff" sub namespace? What is that called anyway? and why?

I have read this:

http://msdn2.microsoft.com/en-us/library/0dx91cw5(VS.80).aspx

So please don't send me to a URL.

For instance.. it says:

>>causes the source code following the declaration to be compiled within that namespace

So what are the benefits of compiling into a namespace?

Just a one paragraph explanation explaining why you use it, the benefits, etc. Not looking for a book, just something you'd explain to a trainee at the coffee pot about namespaces in human language.

Now, in the above url, it says this:

>>Adding to a Namespace. If a namespace is already defined, even outside your project, you can add programming elements to it. To do this, you use a Namespace statement to direct Visual Basic to compile the following elements into that namespace.

It shows an example of using this namespace:

Namespace System.Collections.Generic

But that is an existing namespace. Why would you add to an existing System namespace?

0
Comment
Question by:Starr Duskk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 37

Accepted Solution

by:
samtran0331 earned 1000 total points
ID: 20281703
>>In asp.net, what is the concept of the Namespace?
>>Why do you create this "Stuff" sub namespace? What is that called anyway? and why?
>>So what are the benefits of compiling into a namespace?

In my opinion, in practice, namespaces are just housekeeping.  
How do you want to group and organize your code?
Usage of namespaces (again, just in my experience) is going to be defined either by company standards or the developer.


>>Why would you add to an existing System namespace?

Again, just housekeeping.
If you write some code that manipulates text, do you want it in your own namespace and class and use it with something like "MyNamespace.MyTextFunctions.SomeFunction"
or do you feel it's good enough to be part of System.Text?
and then call it with "System.Text.MyTextFunctions.SomeFunction"
0
 
LVL 10

Assisted Solution

by:Oliver Amaya
Oliver Amaya earned 1000 total points
ID: 20281720
Hi,

A namespace is basically a way to group together classes that perform a common goal, or that have some kind of relationship between them, usually what I do is create one general namespace say MyApp and start distributing the classes that I use in my project in different sub-namespaces, something like MyApp.Data, MyApp.ErrorHandling, MyApp.Controls, etc. that way you get a nice separation of the different layers in the structure of your application.

I don't believe it's a good practice to add to any of the existing namespaces in the .NET framework, that would just create confusion to anybody using your classes and result in not being able to tell which assemblies are needed as references to a project in order to use them.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question