Comments (6)
Hi, thanks for your comment. I believe the one piece you are missing is aggregation. It could be kind of confusing, but for the context of this app, Composition means type Embedding composition. In other words you will need to embed one structure into another to see the composition link. In the same way MyStruct2 includes MyStruct1
//MyStruct2 will be direclty composed of MyStruct1 so it will have a composition relationship with it
type MyStruct2 struct {
MyStruct1
}
In the case of this code
//MyStruct3 will have a foo() function but the return value is not a bool, so it will not have any relationship with MyInterface
type MyStruct3 struct {
Foo MyStruct1
}
Foo is a field of MyStruct3. That kind of representation, although it is a composition, it is done through an aggregation link. Aggregations are optional in the command line interface. They are only shown if you include the -show-aggregations
flag in the command line call. Have you tried that?
from goplantuml.
Ok, I finally made it work with the -show-aggregations
flag. This was something I already tried before but apparently the go get github.com/jfeliu007..
commands are not fetching the lastest version, so I was using an outdated one.
I had to manually download the release and build it on order to have the latest version and make aggregation work.
from goplantuml.
I’ll take a look at that to see what’s happening. Thanks. 😁
from goplantuml.
Same issue here with GoPlanUML v1.5 and the show-aggregations
option.
(Simplified main.go)
package main
// HtmlElement
type HtmlElement struct {
name, text string
elements []HtmlElement
}
type HtmlBuilder struct {
rootName string
root HtmlElement
}
Puml
@startuml
namespace main {
class HtmlBuilder << (S,Aquamarine) >> {
- rootName string
- root HtmlElement
+ String() string
+ AddChildFluent(childName string, childText string) *HtmlBuilder
+ Clear()
}
class HtmlElement << (S,Aquamarine) >> {
- name string
- elements []HtmlElement
- string(indent int) string
+ String() string
}
}
@enduml
I just have to say that even if composition and aggregation may look one and the same, the big difference is that if a composed object is destroyed, then the composing object will be as well. This is not the case of an Aggregation. So, embedded fields (unnamed), named field (by struct, interface, or a pointer to a struct) can all be either part of a composition or an aggregation depending on other relationships where a field would be involved too. From my perspective, it's an important distinction to make because a nice diagram may help to focus our search when there is a memory leak in the app for example. Aside from that, it's working pretty well and I really appreciate the effort :)
from goplantuml.
@BigBoulard private aggregations are not rendered unless explicitly ask for it with the -aggregate-private-members options.
Try goplantuml -show-aggregations -aggregate-private-members ./
This is the result I get with the code you presented
@startuml
namespace main {
class HtmlBuilder << (S,Aquamarine) >> {
- rootName string
- root HtmlElement
}
class HtmlElement << (S,Aquamarine) >> {
- name string
- elements []HtmlElement
}
}
"main.HtmlBuilder" o-- "main.HtmlElement"
"main.HtmlElement" o-- "main.HtmlElement"
@enduml
The project makes a distinction between aggregations and composition even at the visual level. :)
try this code
package main
import "os"
// HtmlElement
type HtmlElement struct {
name, text string
elements []HtmlElement
os.File
}
type HtmlBuilder struct {
rootName string
root HtmlElement
}
You will see a difference in how the connections are rendered. os.File
will be rendered as a composition with a filled arrow.
from goplantuml.
@nkcr , @BigBoulard is this issue still relevant?
from goplantuml.
Related Issues (20)
- confusing syntax about composition
- How to use the generated .puml file? HOT 1
- Error processing self HOT 2
- Visualize single function as a functor
- typo
- Parser Panic HOT 5
- zsh: command not found: goplantuml HOT 3
- Add support for layout direction HOT 1
- Add support for hiding package members
- Adding some usage example in the readme HOT 1
- [question] GoLand plugin? HOT 1
- proposal: support mermaid?
- the example of README.md, output not has compositions relation HOT 1
- panic: runtime error: index out of range HOT 1
- Enhancement: Clarify/Improve the `-ignore` usage
- Enhancement: add option to ignore mocks HOT 1
- Whether there are parameters to control not displaying types without methods?
- Add option: Representing dependencies of structures within the same package in a UML class diagram
- Duplicate package names will affect the diagram HOT 1
- Why aren't they convergent?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goplantuml.