tplant icon indicating copy to clipboard operation
tplant copied to clipboard

Problems with composition feature

Open fuhrmanator opened this issue 3 years ago • 4 comments

First, thanks for making tplant! It is very useful!

The composition flag is good, but I'm suggesting the following improvements. Let me use this example from test/Raytracer/Scene.ts:

export interface Scene {
    things: Thing[];
    lights: Light[];
    camera: Camera;
}

The PlantUML produced using the composition flag should be

Scene --> "things" Thing
Scene --> "lights" Light
Scene --> "camera" Camera

Here are my reasons:

  • it should default to a simple association, because it's wrongly showing all associations as whole/part (composition, i.e., *--), many of which are not truly the semantics of composition. It's pretty hard to figure that out from static analysis of source code, I think. Edit: Furthermore, aggregation (to many) isn't really any different than an association in UML, so a simpler link is just to use --.
  • it could/should include navigability, since you can see it from the TypeScript code, e.g. Scene.things: Thing[]; implies one can navigate from the class Scene to one or more Thing. Edit: Hence, I suggest -->.
  • it could contain cardinalities on the association. However, PlantUML has trouble to show both the names of the ends, e.g., "things" Thing as above, and a cardinality such as "*" Thing. Maybe combining them?
Scene --> "things\n*" Thing

which doesn't always look so great, but is useful I think.

Edit: in cases of a single reference, e.g. myThing: Thing the cardinality would be "1"

I'd be happy to try a PR to support some of these things (with tests, of course), if you think they're reasonable.

fuhrmanator avatar Jul 12 '21 20:07 fuhrmanator

Putting up a PR sounds great.

bafolts avatar Jul 12 '21 20:07 bafolts

SInce you merged, can you publish the package on npm?

fuhrmanator avatar Aug 05 '21 18:08 fuhrmanator

Published.

bafolts avatar Aug 06 '21 00:08 bafolts

The issue should probably be closed now, I noticed the 2.3.4, 2.3.5, 2.3.6 and 3.0.0 tags / releases are missing from github

loopingz avatar Aug 10 '21 04:08 loopingz