English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

First off, this question has nothing to do with the horrid, nasty, vile myspace site.

Well, I'm tring to find some reason to get out of doing my general ed homework currently...so I'm looking into my old computer programming book for of my classes.

I had a question on namespaces (the language would be in C++, although I seriously doubt it would actually matter what language it is in...anyway) my book lists the "creation" of the names spaces reason as a standard way to get around the global identifier naming thing, where if I had a identifier inside a header file that had the same name as a global identifier in my program, it would generate a compiler error since the global identifiers in the header file become the global identifiers in my program (client file).

Anyway, my question is, is this REALLY that much of a problem enough to build a function for it into the actual language itslef? I understand that if there WAS no such thing as a namespace, i would have to type the

2007-02-10 17:43:10 · 3 answers · asked by D 4 in Computers & Internet Programming & Design

ClassName::membername before referencing every member of a class (and yes I mean by an object). This honeslty would seem like something that should be dealt with by the programmer, so is it really that big of an issue, and why?


Please answer...I don't want to do my general ed homework....please......?!?!?!

2007-02-10 17:44:40 · update #1

Man I spunk the good englishez, I don't needs no object framework!

2007-02-10 17:46:07 · update #2

answer now...

2007-02-10 17:51:00 · update #3

3 answers

You are assuming that one programmer is writing all aspects of the code. Also namespaces were not necessarily created because of global variables. Imagine if you had two libraries you purchased from a third party in your application. If you were to import both libraries into your application, but they bot defined a class with the same name you code would produce this error.

Namespaces allow classes, variables, etc to exists with the same name because their scope is limited to the namespce instead of the whole application.

Now if you are writing the entire application it might seem unnecessary, but really it can still be useful.

2007-02-10 17:57:53 · answer #1 · answered by kniemczak 2 · 1 0

Considering the wealth of libraries that would have been tiresome to write all over again, if namespace is not implemented, either in C++, Java, C#, Python, or whatever language, then there is only one person can be in charge of writing the libraries, because someone has to coordinate all the identifiers and names to avoid clashes.

If namespacing is a syntactical feature in a language, the coordination is on namespacing and that could've spread to handled by more than one programmer.

2007-02-11 03:33:01 · answer #2 · answered by Andy T 7 · 0 0

Yes this is an important part of the language. For simple programs, not it's not. For larger ones, with multiple people and integration of external libraries, it becomes necessary. The name-spaces in C++ make this viable.

Look at Java's "packages" (or C#) for the next generation of this. It has really allowed Java to be pluggable, libraries to be upgradeable, and large (huge) programs to be organized and understandable. Much modern software wouldn't be feasible without it.

2007-02-11 02:56:42 · answer #3 · answered by ndp8 1 · 1 0

fedest.com, questions and answers