Giter Club home page Giter Club logo

Comments (6)

jfeliu007 avatar jfeliu007 commented on August 17, 2024

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.

nkcr avatar nkcr commented on August 17, 2024

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.

jfeliu007 avatar jfeliu007 commented on August 17, 2024

I’ll take a look at that to see what’s happening. Thanks. 😁

from goplantuml.

BigBoulard avatar BigBoulard commented on August 17, 2024

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

png

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.

jfeliu007 avatar jfeliu007 commented on August 17, 2024

@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.

jfeliu007 avatar jfeliu007 commented on August 17, 2024

@nkcr , @BigBoulard is this issue still relevant?

from goplantuml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.