How can I get components to have local scope inside of packages?

0 votes
asked Mar 24, 2014 in To be sorted by anonymous
I'm working on a project where I need to diagram the relationships between components within different packages.

For example, I have roughly

package "first" {

  node {

      [router]

   }

  node "physical 1" {

      [Logical_VLAN_10] - router

  }

  ...

}

 

package "second" {

  node {

     [router]  // doesn't work, not unique

  }

 node "physical 1" {

     [Logical_VLAN_10] - [router]

     // now I want to do this

     // I want to connect the vlan to the VLAN in the OTHER package, but they both have the same name

     // I cannot just use different names because I have 100s of these devices.

     // Is there any scoping? So I can access devices per package? Instead of every identifier being global?

     [Logical_VLAN_10] - package:first.[Logical_VLAN_10]

     

  }

  ...

}

1 Answer

+1 vote
answered Mar 25, 2014 by plantuml (298,440 points)

As you have mentioned, identifiers are global so you will have to do something like:

@startuml
package "first" {
  node {
      component [router] as first_router
  }
  node "physical 1" {
      component [Logical_VLAN_10] as first_Logical_VLAN_10
      first_Logical_VLAN_10 - first_router
  }
}

package "second" {
 node {
      component [router] as second_router
  }
node "physical 2" {
     component [Logical_VLAN_10] as second_Logical_VLAN_10
     first_Logical_VLAN_10 - second_Logical_VLAN_10
  }
}
@enduml


We understand that this is may not be very convenient for you, so we are ok about looking for an extended syntax.
(BTW, somehow, this is already working for classes - see http://plantuml.sourceforge.net/classes.html#Namespaces - but not for other diagrams).

Keep also in mind that we have to preserve ascending compatibility.

We could create a new "set namespaceSeparator" instruction.
Using this, we could have:

@startuml
set namespaceSeparator .
package "first" {
  node {
      [router]
  }
  node "physical 1" {
      [Logical_VLAN_10] - router
  }
}

package "second" {
 node {
    'this would work because we have define a namespaceSeparator
    [router]
  }
  node "physical 1" {
    [Logical_VLAN_10] - [router]
    [Logical_VLAN_10] - first."physical 1".Logical_VLAN_10
  }
}
@enduml


Note that "node" defines also a namespace, so we would have to use first."physical 1".Logical_VLAN_10 to denotate the first Logical_VLAN_10.
Any though about this suggestion ?

commented Mar 25, 2014 by anonymous
First of all, thanks for replying to my question and showing me how to do it with the current syntax.

I fully support the namespace separator idea, it was exactly what I wanted to begin with. If you guys could actually implement that concept, that would be great.
commented Apr 9, 2014 by anonymous
I agree, the namespace separator would be most helpful.
...