Author Topic: How do I turn off Namespaces in code generation?  (Read 2483 times)

sl@sh

  • EA User
  • **
  • Posts: 85
  • Karma: +0/-0
    • View Profile
How do I turn off Namespaces in code generation?
« on: July 05, 2007, 04:37:40 am »
I've checked the search, but the options suggested within the postings I found (under Tools/Options/Source Code Engeneering, or package context menu-->Set as Namespace Root/Clear Namespace Root) are already set to the correct values - still, on generating new code, EA will inexplicably use the names of my packages as Namespace names and put them in front of all the definitions! :(

A couple of weeks ago everything worked fine, so apparently, at some point I inadvertantly changed some setting that now I cannot locate anymore ??? Please help - these packages are not meant to be Namespaces and I don't want then generated.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8064
  • Karma: +118/-20
    • View Profile
Re: How do I turn off Namespaces in code generatio
« Reply #1 on: July 05, 2007, 01:03:03 pm »
If packages are not supposed to be namespaces you can set them to a namespace root and they won't be generated as namespaces.  Alternatively, (depending on your target language) you may be able to turn off namespace generation for that language.  Go to Tools | Options | Source Code Engineering | Your Language.

The option exists for C#, C++ and VB.Net.  (And indirectly I think for object oriented C)

sl@sh

  • EA User
  • **
  • Posts: 85
  • Karma: +0/-0
    • View Profile
Re: How do I turn off Namespaces in code generatio
« Reply #2 on: July 05, 2007, 10:10:57 pm »
Quote
I've checked the search, but the options suggested within the postings I found (under Tools/Options/Source Code Engeneering, or package context menu-->Set as Namespace Root/Clear Namespace Root) are already set to the correct values

Done that - to no avail!

Or are you saying to avoid generating Namespaces I need to set the packages to "Namespace Root"? Sounds a bit counter-intuitive to me if that is the meaning of this option!?

P.S.: tried it - setting the containing package to "Namespace Root" finally did the trick.

I still consider the naming of this option misleading. After thinking about it I found what was my problem: You are thinking of the package hierarchy as equivalent to a namespace hierarchy (which makes sense for Java, but not C++). I wasn't getting what you referred to as 'Root' and just read 'Namespace' - and was thinking to myself: "No, I don't want a namespace for this package - clear that option!"

Basically you are asking the designer to "set" an option if he wants no additional qualifying and "clear" that option if he wants it. It's like asking a user whether he wants to really proceed with a process he started and have him press [Cancel] to avoid the aborting of the proces (which the software considers the sensible approach, even if it is not).

Please consider that in some languages package hierarchies are not equivalent to namespaces. There is no global setting to use or not use namespaces at all (or is there?), which means every sub-package explicitely requires the user to set that option, no matter the language, no matter how often he did it before for other languages!

Please change this option to something that is obvious and positive, such as "package is namespace" instead of "package is Namespace Root" ("Root"? what would it be "root" of??), and inherit that setting to subpackages!
« Last Edit: July 05, 2007, 10:30:33 pm by sl@sh »