Book a Demo

Author Topic: single namespace for all packages below one  (Read 5275 times)

cem

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
single namespace for all packages below one
« on: February 21, 2011, 10:13:11 pm »
Hi,

I need to set a common namespace for all packages below a package.
Let's say I have something like:
P1
  P1_1
    Class1
  P1_2
    Class2
    P1_2_1
      Class3

I need Class1, Class2 and Class3, all have the namespace P1, not P1.P1_1, P1_2, P1_2_1, etc...

Is it possible? Or is there any means to set explicitly set namespace of the elements?

Thank you...

SomersetGraham

  • EA User
  • **
  • Posts: 376
  • Karma: +1/-0
    • View Profile
Re: single namespace for all packages below one
« Reply #1 on: February 21, 2011, 10:30:28 pm »
Hi
I think you need namspace root
Using V12

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: single namespace for all packages below one
« Reply #2 on: February 21, 2011, 10:47:55 pm »
Right-click on package P1 then Code Engineering|Set as NameSpace Root should do it.

Geert

cem

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: single namespace for all packages below one
« Reply #3 on: February 22, 2011, 06:44:46 am »
Thanks for help!

Setting namespace root causes generation of namespaces starting from P1 and the packages below generate nested namespaces. I wish to generate one topmost namespace and no other (nested or not).

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: single namespace for all packages below one
« Reply #4 on: February 22, 2011, 12:52:37 pm »
Quote
Thanks for help!

Setting namespace root causes generation of namespaces starting from P1 and the packages below generate nested namespaces. I wish to generate one topmost namespace and no other (nested or not).
Hi cem,

I think this is actually a more common problem than people think...

Namespace is actually an orthogonal concept to physical structure.

Often, the two overlap, but there is no particular requirement for them to do so (as in your case).

UML, I think, has conflated the two concepts.  EA helps alleviate the matter by providing the namespace root feature - but that doesn't solve your problem.

It will require a significant change in EA to allow your requirement, I think.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

cem

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: single namespace for all packages below one
« Reply #5 on: February 24, 2011, 06:40:24 am »
Thank you.
I'll be looking for a solution.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: single namespace for all packages below one
« Reply #6 on: February 24, 2011, 03:51:52 pm »
Quote
Thank you.
I'll be looking for a solution.
I don't believe there is one - within the current architecture of EA.

Actually, in a spare moment (yes- it WAS sitting on the "throne"), it suddenly occurred to me that when UML mentions Namespace, they mean it in terms of requiring uniqueness of names within the namespace.

They may NOT be talking about the namespace in any code that you are modelling.

Although most (All?) modelling tools seem to make the UML Namespace and the Code Namespace the same, I don't think that's correct.

The UML Namespace is about locating the item within the UML model the Code Namespace is about locating the (code) contents of the item within the programming namespace(s).  Now for many situation/languages once you've established a Namespace Root, the two are (effectively) the same.

But in many circumstances, they need not (and I would argue should not) be the same.

It seems to me that the code namespace is an additional property of the item (similar to the schema/owner of a database table) and therefore could be handled in the same way by EA.: Add a tagged value called CodeNamespace if the Code namespace doesn't correspond to the UML Namespace.  The code generation templates could then be upgraded to make use of that.

(The code synchronizer would also need to be adjusted).

Thoughts?
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!