Incorrect interpretering diagram type when having "allowmixing" in Component Diagram for JSON Data

0 votes
asked Aug 5 in Bug by xiaoqi (380 points)
Hello,

I'm learning referen guide 7.17 sample "Display JSON data on Component Diagram", see the code in the online server:

https://www.plantuml.com/plantuml/uml/HS-noi903C3nFKyHClTxWGuV5GTHH44d4OUZJSl9DJdIAnR5TxT5MZFz-ML9YYuvItqR05m8-cZzuAK1ABMDAYm9rtE1byHMkv9nEnV0iiQ__v_do4DKIm3tJWLtv-C1Nu3ZK6szJvGZhM8CJDbNE__a2VVEcWLB3MgZNkd45ML86sEMAIuy7KitU0CKBDNum0S0

When as reference guide sample, having the "allowmixing", the interface element is displayed as the one in Class Diagram, it can only be correctly displayed as Component Diagram's interface when I comment the "allowmixing".

May I know the reason? Thanks.

Xiaoqi

1 Answer

0 votes
answered Aug 6 by Martin (9,120 points)
selected Aug 6 by xiaoqi
 
Best answer

Normally you are either drawing a Class diagram, or you are drawing a Deployment diagram - each diagram has its own syntax and list of keywords.  And it won't let you mix the two ... without using 'allowmixing'!

The "Interface" keyword is interesting because it is the only? keyword that exists in both Class diagrams and Deployment diagrams but for completely different uses.  So if you have turned on 'allowmixing' then Plantuml can't know which you want, and defaults to the class diagram version.  JSON also exists in both diagrams, but has the same syntax and look in both diagram types, so it doesn't matter which it uses during 'allowmixing' - in your example the JSON object is irrelevant, the allowmixing has been added to be able to have the deployment-component and the class-interface coexisting together.

I'm not sure if there's a sensible way to include the deployment diagram's Interface instead of the class diagram one.  But you force it if you can find a syntax difference between the two diagrams to exploit, for example:

@startuml
allowmixing
component C
interface i [
i]
@enduml

Which exploits the fact that the deployment diagram's Interface allows a description in square brackets, but the class Interface doesn't recognise that syntax - so the ambiguity is resolved.

Best manual reference explaining is:

8.18 Mixing Deployment (Usecase, Component, Deployment) element within a Class or Object diagram
In order to add a Deployment element or a State element within a Class or Object diagram, you can use the allowmixing or allow_mixing directive.

commented Aug 6 by xiaoqi (380 points)
Thanks for your answer, understood this tricky situation for "interface" element.

Now I'm moving chapter 8 to learn and practice Deployment Diagram, will further evaluate what you've suggested.
...