Nested packages. Which code is "better"?

0 votes
asked Mar 16 by poi (920 points)
edited Mar 16 by poi

I generate PlantUML code programmatically. The two script below produce identical diagrams.  I'm tempted to use the format of the first script, because it makes my program simpler. Question: Are there other reasons to chose one over the other?

@startuml
title Packages - Class Diagram
package Folder <<Folder>> {
package Rectangle <<Folder>> {
  class Worker1
}}
package Folder <<Folder>> {
package Rectangle <<Folder>> {
  class Worker2
}}
package Folder <<Folder>> {
package Rectangle <<Folder>> {
  class Worker3
}}
package Folder <<Folder>> {
  class Worker
}
Worker1 --> Worker2
Worker2 --> Worker3
@enduml

 

@startuml
title Packages - Class Diagram
package Folder <<Folder>> {
package Rectangle <<Folder>> {
  class Worker1
  class Worker2
  class Worker3
}}
package Folder <<Folder>> {
  class Worker
}
Worker1 --> Worker2
Worker2 --> Worker3
@enduml

 

1 Answer

0 votes
answered Mar 16 by plantuml (134,650 points)
PlantUML will support both syntax.

But I think that the second one is better : the code is shorter. Especially if this is generated, the first script will be very verbose and difficult to debug in case of issues.

Just my two cents!
...