Qualified names in packages

0 votes
asked Jan 12, 2015 in To be sorted by wolfgang_fahl (160 points)
the following diagram does not show two different packages with both having Structure, Content and Form Classes but just one. I think it's a bug because within a package the classes should be "scoped" that means Problem.Structure is something different then Solution.Structure!

Package Problem {
  class Structure {
  }
  class Content {
  }
  class Form {
  }

  Structure -- Content
  Content -- Form
  hide Structure circle
  hide Content circle
  hide Form circle
}
package Solution {
  class Structure {
  }
  class Content {
  }
  class Form {
  }

  Structure -- Content
  Content -- Form
  hide Structure circle
  hide Content circle
  hide Form circle

}

1 Answer

+1 vote
answered Jan 12, 2015 by plantuml (295,000 points)
selected Jan 12, 2015 by wolfgang_fahl
 
Best answer

Hello,

You should use namespace instead of package. See http://plantuml.sourceforge.net/classes.html#Namespaces

namespace Problem {
  class Structure {
  }
  class Content {
  }
  class Form {
  }

  Structure -- Content
  Content -- Form
  hide Structure circle
  hide Content circle
  hide Form circle
}
namespace Solution {
  class Structure {
  }
  class Content {
  }
  class Form {
  }

  Structure -- Content
  Content -- Form
  hide Structure circle
  hide Content circle
  hide Form circle

}


Hope it helps!
 

commented Jan 12, 2015 by wolfgang_fahl (160 points)
So far i was always assuming that package and namespace are synonyms. E.g. in java a package will create a namespace just like the namespace keyword in C# will create a namespace. I think the current behaviour is counter-intuitive. Your answer is a great workaround though!
commented Jan 12, 2015 by plantuml (295,000 points)
Somehow, we agree that this is not very intuitive.
Infortunatly, PlantUML language has been build iteratively.
When packages have been introduced, they did not define any scope.
Some users use to complain about this, but as we want to keep ascending compatibility, it was difficult to change this behaviour.
Instead, we have introduced a new keyword (that is "namespace") at that time.

Sure that this is not perfect!
...