Could you suggest a better "unquoted" solution for !preprocessorV2 the following legacy piece of code?

0 votes
asked Apr 29 in Question / help by boshka (2,680 points)
edited Apr 29 by boshka

I have an issue while migrating my code to !preprocessorV2:

my legacy code is generated as follows:

http://www.plantuml.com/plantuml/uml/SoWkIImgAStDuKhEpot8pqlDAr5GygrKS8Rnb1GIYnLyA-5yXMekBWKGK4n9JSlCIqMMYqyiYVSCSVMDzmt29anG7uezNBLSo6uAzGIx9DIp6YI1mr9TNQ02AmNFajHSBeVKl1IWlm00

It appears that, to migrate to preprocessorV2, the code should be modified as follows:

http://www.plantuml.com/plantuml/uml/SoWkIImgAStDuL8iA4ejACfFJYqkpYyAC-BYIixFBSZFIyqhKL3ohLHmXl6K51AB5NmhuNo5QYuk1H1GH1ACJoo9zmnnzLMm1Mb6wCMjCjut2AWOYmHNBOfJGZt13WZrh0P9u318LnUem4h1ioGrbyiXDIy5w3y0

So, as one can see, it is about wrapping with quotes the value and not wrapping with quotes the variable name.

Note, that the legacy code worked fine without any quotes and the problem is that in case of the preprocessorV2 format I shall somehow know exactly if a string is a value or a var name. Could we do something about it? Can we keep the unquoted format too? Or, can var names be evaluated within quotes too?

So that in case of preprocessorV2 I could do either (a):

component "My Component" as MyComponent {

     !MyComponent_at_ITEM = "MyComponent"
     !MyComponent_at_ITEM_MR = "MyComponent_at_ITEM"

}

component "UI" as UI{
}

MyComponent_at_ITEM_MR -- UI: Item


Or (b):

component "My Component" as MyComponent {

     !MyComponent_at_ITEM = MyComponent
     !MyComponent_at_ITEM_MR = MyComponent_at_ITEM

}

component "UI" as UI{
}

MyComponent_at_ITEM_MR -- UI: Item


As well, I see that now you have to put the definitions in a strict order (you cannot use a definition, before you define it). Earlier the order did not matter

1 Answer

0 votes
answered Apr 29 by plantuml (198,780 points)

So yes, now variables setting order matters.
However, function definition order does not matter.
(Note that this is close to many programming language convention)

I also suggest that you start variables and function name by a $ : this makes more clear for reader to know what is a variable and what is not.

So I would suggest two different solutions:

@startuml
!preprocessorV2

component "My Component" as MyComponent {
     !function $MyComponent_at_ITEM_MR() return $MyComponent_at_ITEM()
     !function $MyComponent_at_ITEM() return "MyComponent"
}

component "UI" as UI{
}

$MyComponent_at_ITEM_MR() -- UI: Item
@enduml

or :

@startuml
!preprocessorV2
component "My Component" as MyComponent {
     !$MyComponent_at_ITEM = "MyComponent"
     !$MyComponent_at_ITEM_MR = $MyComponent_at_ITEM
}

component "UI" as UI{
}

$MyComponent_at_ITEM_MR -- UI: Item
@enduml

Does this fit your need ?

...