Classes of same names but in different packages are represented only once

0 votes
asked May 31, 2017 in Closed question / help by LArch (140 points)
recategorized May 31, 2017 by LArch

Hi plantUML team,

I am using this great tool to generate class diagrams recently, and have a question - 

Classes of same names but in different packages are represented only once, and all others are ignored.

For example:

package pack {

                 class MyClass {

                 }

                 package subpack {

                                class MyClass {

                                }

                 }

}

Here MyClass is represented in the graphic, but MyClass is ignored.

Any suggestion about how to handle this?

Thanks!

1 Answer

+1 vote
answered May 31, 2017 by plantuml (294,960 points)
commented May 31, 2017 by LArch (140 points)
hi, thanks for the reply.
I am developing a simple tool to output plantUML text formats, is it safe to use namespace instead of package for all cases?
I read http://plantuml.com/class-diagram , it seems to me that the benefits of using package is I can define relationships between packages and styles, any other tradeoff if use namespace?
Thanks!
commented May 31, 2017 by plantuml (294,960 points)
No, there should be no tradeiff if use namespace.
For example, the following example is working fine:

@startuml
skinparam packageStyle rectangle

namespace foo1.foo2 {
}

namespace foo1.foo2.foo3 {
  class Object
}

foo1.foo2 +-- foo1.foo2.foo3

namespace foo6 <<Database>> {
  class Class6
}
@enduml

http://www.plantuml.com/plantuml/uml/ROun2i9044NxFSNq4a65L244jBV82NxMCMXsDs5dB4IykxEL4cnUy-O_fXD5raSCJgPRMf0HQO6VC7Alpy2KsIlI6DYvXCXYakawpxkjOKylz_uh2WvcYNo029s7kuNAyNUxgQhLO9MggMbEK0mGRjkVsh6mBhMEqyM-_m00

If you find any issues, please tell us : it is probably a bug.

The truth is, if we would restart PlantUML from now, we would implement "package" as they are implemented in Java (that is, allowing class with the same name to exist in different packages).

Unfortunately, since we care about ascending compatibility, when we realize that having implemented a no-namespace-aware "package" was an mistake, it was too late : we did not want to break the behaviour of existing PlantUML diagrams by changing "package" behaviour.

So we just add a new keyword (that is "namespace") to allow regular "Java package". Hope this is more clear!
commented Jun 14, 2017 by LArch (140 points)
Thank you very much!
...