what is the lovepurpose of namespaces in c#

Is is OK to use C++ namespaces like namespaces are used in C#? Namely, to
hierarchically organize code. For example:
std::Container
49132 articles.
1 followers.
18 Replies
[PageSpeed]
MikeP wrote:
& Is is OK to use C++ namespaces like namespaces are used in C#? Namely, to
& hierarchically organize code. For example:
std::Container
Yes, namespaces can be nested. You can, however, not do anything about what
is in std. Your own code base can be organized quite hierarchically.
Kai-Uwe Bux
On Sun, , Kai-Uwe Bux wrote:
& MikeP wrote:
&& Is is OK to use C++ namespaces like namespaces are used in C#? Namely, to
&& hierarchically organize code. For example:
std::Container
& Yes, namespaces can be nested. You can, however, not do anything about what
& is in std. Your own code base can be organized quite hierarchically.
I've even seen namespaces used as what's-its-name in Java:
com::company::division::product_family::product::subsystem::...
Not that I recommend it ...
// Jorgen Grahn &grahn@
snipabacken.se&
&MikeP& &mp011011@some.org& wrote in message
news:iofbjv$h4l$1@speranza.aioe.org...
& Is is OK to use C++ namespaces like namespaces are used in C#? Namely, to
& hierarchically organize code. For example:
std::Container
This depends what you mean by heirarchically organise code.
I see a namespace as more or less the same in both languages although I have
forgot alomost all I knew about C#, but AFAIR it still just a collective
scoping of identifiers.
Its like giving a name to something, an object, function or whatever, a
second name so we can have two Joes. A Joe smith and a Joe Jones for
Heirarchy of code means , to me at least, priveldges and ownership. But I
dont think you mean this, so I'm probably babbling .
Jorgen Grahn &grahn+nntp@snipabacken.se& wrote:
& I've even seen namespaces used as what's-its-name in Java:
& com::company::division::product_family::product::subsystem::...
& Not that I recommend it ...
At some point you might want to create a namespace alias (which is
possible in C++), so that it becomes something like ccdpps::...
Not that it's any more readable, but...
Kai-Uwe Bux && writes:
&Yes, namespaces can be nested. You can, however, not do anything about what
&is in std. Your own code base can be organized quite hierarchically.
?... about what is in ::std?. One can declare:
namespace alpha { namespace std { ...
On 4/17/ PM, MikeP wrote:
& Is is OK to use C++ namespaces like namespaces are used in C#? Namely, to
& hierarchically organize code. For example:
std::Container
First off, C# features are off-topic here unless you define what they
You cannot just ask about another language as if it is common
knowledge.
What is your definition of &hierarchically organize code&?
What would be the purpose?
And what are the trade-offs (if you happen
to have thought of any)?
If you have a problem and a solution in C++, do post it, and let's
If you just want C++ to be &like &insert the name of another
language&&, then stop wasting your time, our time, and the bandwidth.
Either use C++ or use the other language.
I do not respond to top-posted replies, please don't ask
Victor Bazarov wrote:
& On 4/17/ PM, MikeP wrote:
&& Is is OK to use C++ namespaces like namespaces are used in C#?
&& Namely, to hierarchically organize code. For example:
std::Container
& First off, C# features are off-topic here unless you define what they
You cannot just ask about another language as if it is common
& knowledge.
What is your definition of &hierarchically organize code&?
& What would be the purpose?
And what are the trade-offs (if you happen
& to have thought of any)?
& If you have a problem and a solution in C++, do post it, and let's
& discuss.
If you just want C++ to be &like &insert the name of another
& language&&, then stop wasting your time, our time, and the bandwidth.
& Either use C++ or use the other language.
Spoken like a true &fanboy&. Don't you find it odd that everyone but you
understood the question? It seems you need to do some introspection. And
you're surely not doing C++ any good deed by running your mouth off like
that, FWIW.
11:36, MikeP wrote:
& Victor Bazarov wrote:
&& On 4/17/ PM, MikeP wrote:
&&& Is is OK to use C++ namespaces like namespaces are used in C#?
&&& Namely, to hierarchically organize code. For example:
std::Container
&& First off, C# features are off-topic here unless you define what they
You cannot just ask about another language as if it is common
&& knowledge.
What is your definition of &hierarchically organize code&?
&& What would be the purpose?
And what are the trade-offs (if you happen
&& to have thought of any)?
&& If you have a problem and a solution in C++, do post it, and let's
&& discuss.
If you just want C++ to be &like&insert the name of another
&& language&&, then stop wasting your time, our time, and the bandwidth.
&& Either use C++ or use the other language.
& Spoken like a true &fanboy&. Don't you find it odd that everyone but you
& understood the question? It seems you need to do some introspection. And
& you're surely not doing C++ any good deed by running your mouth off like
& that, FWIW.
* MikeP, on 18.04.:
& Victor Bazarov wrote:
&& On 4/17/ PM, MikeP wrote:
&&& Is is OK to use C++ namespaces like namespaces are used in C#?
&&& Namely, to hierarchically organize code. For example:
std::Container
&& First off, C# features are off-topic here unless you define what they
You cannot just ask about another language as if it is common
&& knowledge.
What is your definition of &hierarchically organize code&?
&& What would be the purpose?
And what are the trade-offs (if you happen
&& to have thought of any)?
&& If you have a problem and a solution in C++, do post it, and let's
&& discuss.
If you just want C++ to be &like&insert the name of another
&& language&&, then stop wasting your time, our time, and the bandwidth.
&& Either use C++ or use the other language.
& Spoken like a true &fanboy&. Don't you find it odd that everyone but you
& understood the question?
They guessed.
It apparently so happened that they guessed right about what you had in mind,
but equally easily the could have guessed wrong (we're not telepaths), and then
it would just be a waste of time.
Victor is right, you're wasting our time.
& It seems you need to do some introspection. And
& you're surely not doing C++ any good deed by running your mouth off like
& that, FWIW.
He did not, but you are.
And you're anonymous.
So my guess is, given that Victor is right and posts with full name and is a
moderator of clc++m and has not gone ad hominem and has not employed derogatory
labeling, while your are wrong and posts anonymously and has no standing in the
community and do use ad hominem and has now employed derogatory labeling, given
that, I guess that you're effectively a troll (perhaps you're very young?).
Cheers & hth.,
blog at &url: &
On Sun, , Kai-Uwe Bux wrote:
& MikeP wrote:
&& Is is OK to use C++ namespaces like namespaces are used in C#? Namely, to
&& hierarchically organize code. For example:
std::Container
& Yes, namespaces can be nested. You can, however, not do anything about what
& is in std. Your own code base can be organized quite hierarchically.
But like someone else wrote, what's the point?
I think most C++ people stick to a very flat namespace design. Same in
Python. For C# and other languages/cultures which I don't know, I have
no idea what people do, or why.
// Jorgen Grahn &grahn@
snipabacken.se&
Jorgen Grahn wrote:
& On Sun, , Kai-Uwe Bux wrote:
&& MikeP wrote:
&&& Is is OK to use C++ namespaces like namespaces are used in C#?
&&& Namely, to hierarchically organize code. For example:
std::Container
&& Yes, namespaces can be nested. You can, however, not do anything
&& about what is in std. Your own code base can be organized quite
&& hierarchically.
& But like someone else wrote, what's the point?
Code organization. Also, it forces one to think more in terms of
separation of concerns/orthogonality. My guess is that the standard C++
library is all in one namespace because the library (especially the C
part) is so intertwined that nothing but a complete rework could result
in a nice partitioning using namespaces. Had namespaces been in the
though process way back when, and exploited to their potential, a much
nicer standard library might indeed exist. And who doesn't/hasn't
&refactored& at least a part of the standard library (C or C++) at some
& I think most C++ people stick to a very flat namespace design.
That's &neither here nor there&. The question is what the best practices
are (for new code). Orthogonality is good. That &most people do flat& (if
that is the case) may mean that most programmers are novice designers
(probably true).
& Python. For C# and other languages/cultures which I don't know, I have
& no idea what people do, or why.
I ventured a guess above. Actually two, if you count that &legacy& code
can't really take advantage of namespaces to any real extent.
* MikeP, on 20.04.:
& Jorgen Grahn wrote:
&& On Sun, , Kai-Uwe Bux wrote:
&&& MikeP wrote:
&&&& Is is OK to use C++ namespaces like namespaces are used in C#?
&&&& Namely, to hierarchically organize code. For example:
std::Container
&&& Yes, namespaces can be nested. You can, however, not do anything
&&& about what is in std. Your own code base can be organized quite
&&& hierarchically.
&& But like someone else wrote, what's the point?
& Code organization. Also, it forces one to think more in terms of
& separation of concerns/orthogonality. My guess is that the standard C++
& library is all in one namespace
it isn't
& because the library (especially the C
& part) is so intertwined that nothing but a complete rework could result
& in a nice partitioning using namespaces.
the &because& is wrong. the standard library was defined in the same process
that introduced namespaces
& Had namespaces been in the
& though process way back when
they were, see above
&, and exploited to their potential, a much
& nicer standard library might indeed exist. And who doesn't/hasn't
& &refactored& at least a part of the standard library (C or C++) at some
you would have to define '&refactored&' to get any meaningful answer to that
for the second time
your readers are not telepaths
&& I think most C++ people stick to a very flat namespace design.
& That's &neither here nor there&. The question is what the best practices
& are (for new code). Orthogonality is good. That &most people do flat& (if
& that is the case) may mean that most programmers are novice designers
& (probably true).
&& Same in
&& Python. For C# and other languages/cultures which I don't know, I have
&& no idea what people do, or why.
& I ventured a guess above. Actually two, if you count that &legacy& code
& can't really take advantage of namespaces to any real extent.
it's not uncommon to nest namespaces
neither is it very common
check out libraries like boost
blog at &url: &
On 04/20/11 05:02 PM, Alf P. Steinbach /Usenet wrote:
& * MikeP, on 20.04.:
&& , and exploited to their potential, a much
&& nicer standard library might indeed exist. And who doesn't/hasn't
&& &refactored& at least a part of the standard library (C or C++) at some
& you would have to define '&refactored&' to get any meaningful answer to that
Using the normal definition of refactor, what he proposes is the
Refactoring modifies the code without changing its behaviour
or interface.
Ian Collins
Alf P. Steinbach /Usenet wrote:
& * MikeP, on 20.04.:
&& Jorgen Grahn wrote:
&&& On Sun, , Kai-Uwe Bux wrote:
&&&& MikeP wrote:
&&&&& Is is OK to use C++ namespaces like namespaces are used in C#?
&&&&& Namely, to hierarchically organize code. For example:
std::Container
&&&& Yes, namespaces can be nested. You can, however, not do anything
&&&& about what is in std. Your own code base can be organized quite
&&&& hierarchically.
&&& But like someone else wrote, what's the point?
&& Code organization. Also, it forces one to think more in terms of
&& separation of concerns/orthogonality. My guess is that the standard
&& C++ library is all in one namespace
& it isn't
You are missing &my point& (of being in C# land for the last week and
&liking it&(don't ask why I don't like it)). I know what C++ is and I
told you many years ago I don't like that camel process having come out
of &parallel& world&, but y'all keep on doing the same thing, so I know
you, can research you, and find you all over the place. Someone said
something about &something& and getting the same result, but persisting
with that (someone chime in with the annecdote please).
I don't like that. And I won't play.
&& because the library (especially the C
&& part) is so intertwined that nothing but a complete rework could
&& result in a nice partitioning using namespaces.
& the &because& is wrong. the standard library was defined in the same
& process that introduced namespaces
Did you just say: &the world is flat&? Dude, ...
&& Had namespaces been in the
&& though process way back when
& they were, see above
&& , and exploited to their potential, a much
&& nicer standard library might indeed exist. And who doesn't/hasn't
&& &refactored& at least a part of the standard library (C or C++) at
&& some time?
& you would have to define '&refactored&' to get any meaningful answer
To you and your &whatever& maybe. What do you want? War? Epitaph? What?
Do tell? What's your beef?
& for the second time
& your readers are not telepaths
I assure you my quest for reassurance was answered long ago and that your
straggling banter about whatever is off-topic in MY post.
(And I have
not &readers&).
And shut your mouth with &for the second time&.
&&& I think most C++ people stick to a very flat namespace design.
&& That's &neither here nor there&. The question is what the best
&& practices are (for new code). Orthogonality is good. That &most
&& people do flat& (if that is the case) may mean that most programmers
&& are novice designers (probably true).
&&& Same in
&&& Python. For C# and other languages/cultures which I don't know, I
&&& have no idea what people do, or why.
&& I ventured a guess above. Actually two, if you count that &legacy&
&& code can't really take advantage of namespaces to any real extent.
& it's not uncommon to nest namespaces
& neither is it very common
& check out libraries like boost
I don't feel sorry for you.
I am not you.
* MikeP, on 20.04.:
& Alf P. Steinbach /Usenet wrote:
&& * MikeP, on 20.04.:
&&& Jorgen Grahn wrote:
&&&& On Sun, , Kai-Uwe Bux wrote:
&&&&& MikeP wrote:
&&&&&& Is is OK to use C++ namespaces like namespaces are used in C#?
&&&&&& Namely, to hierarchically organize code. For example:
std::Container
&&&&& Yes, namespaces can be nested. You can, however, not do anything
&&&&& about what is in std. Your own code base can be organized quite
&&&&& hierarchically.
&&&& But like someone else wrote, what's the point?
&&& Code organization. Also, it forces one to think more in terms of
&&& separation of concerns/orthogonality. My guess is that the standard
&&& C++ library is all in one namespace
&& it isn't
& You are missing &my point& (of being in C# land for the last week and
& &liking it&(don't ask why I don't like it)).
wtf do you mean
blog at &url: &
Alf P. Steinbach /Usenet wrote:
& * MikeP, on 20.04.:
&& Alf P. Steinbach /Usenet wrote:
&&& * MikeP, on 20.04.:
&&&& Jorgen Grahn wrote:
&&&&& On Sun, , Kai-Uwe Bux wrote:
&&&&&& MikeP wrote:
&&&&&&& Is is OK to use C++ namespaces like namespaces are used in C#?
&&&&&&& Namely, to hierarchically organize code. For example:
std::Container
&&&&&& Yes, namespaces can be nested. You can, however, not do anything
&&&&&& about what is in std. Your own code base can be organized quite
&&&&&& hierarchically.
&&&&& But like someone else wrote, what's the point?
&&&& Code organization. Also, it forces one to think more in terms of
&&&& separation of concerns/orthogonality. My guess is that the standard
&&&& C++ library is all in one namespace
&&& it isn't
&& You are missing &my point& (of being in C# land for the last week and
&& &liking it&(don't ask why I don't like it)).
& wtf do you mean
Do you mean seriously or jokingly? On the serious side, I haven't
programmed in C# until a week ago and it is quite fine for doing the
&quick and dirty& program (probably more than that). On the namespace
thing, that level of organization capability beyond classes and files is
nice, and C# is one example of such usage. So, just simple thoughts.
On Wed, , MikeP wrote:
& Jorgen Grahn wrote:
&& I think most C++ people stick to a very flat namespace design.
& That's &neither here nor there&. The question is what the best practices
& are (for new code). Orthogonality is good. That &most people do flat& (if
& that is the case) may mean that most programmers are novice designers
& (probably true).
I just stated what I /think/; didn't claim to answer any particular
question or to be right. (And by &very flat& I meant a handful of
namespaces, occasionally nested one level.)
// Jorgen Grahn &grahn@
snipabacken.se&
Jorgen Grahn wrote:
& On Wed, , MikeP wrote:
&& Jorgen Grahn wrote:
&&& I think most C++ people stick to a very flat namespace design.
&& That's &neither here nor there&. The question is what the best
&& practices are (for new code). Orthogonality is good. That &most
&& people do flat& (if that is the case) may mean that most programmers
&& are novice designers (probably true).
& I just stated what I /think/; didn't claim to answer any particular
& question or to be right. (And by &very flat& I meant a handful of
& namespaces, occasionally nested one level.)
I don't mind a bunch of namespaces if/when it is appropriate. Flat (as in
most at the same level) occurs naturally though. .Net is pretty flat,
e.g., but has a lot of namespaces. Flat especially if you consider that
the &System& namespace could have been an unnamed global namespace. My
own code uses the global namespace as a &level zero& upon which all other
namespaces are built on top of. I don't see any value in having &level
zero& in a named namespace and find it &unwieldly& to do so. Anyway, one
reason to keep namespace hiearchies flat is to keep complexity of usage
low (less to remember: &now in what namespace did that class get tucked
away?&. OTOH, the C++ standard library is too flat for my liking. If all
you want is to keep different developers from walking on each other, then
the One Big Nam I consider that pretty much not
using namespaces though for it gives no benefit to code developed and
used by one developer/team/company (save for keeping it distinct from the
standard library names).

我要回帖

更多关于 namespaces 的文章

 

随机推荐