goadesign / goadesign/model

Feature request: make using variables easier

Open
#862 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
467
Forks
23
Avg merge
6m
Merged PRs (30d)
8

Description

Hello,

I find that using strings to reference elements prevents us from taking advantage of the features offered by our IDEs (like static analysis, re-factoring, etc.). However, defining variables brings a lot of scopes challenges.

The following does not work:
```
var _ = Design(func() {
SoftwareSystem("mysystem1", func() {
container1 := Container("mycontainer1", func() {
})
})

SoftwareSystem("mysystem2", func() {
Container("mycontainer2", func() {
Uses(container1, "Uses")
})
})
})
```

We have to pre-declare variables like the following:
```
var _ = Design(func() {
var container1 *expr.Container

SoftwareSystem("mysystem1", func() {
container1 = Container("mycontainer1", func() {
})
})

SoftwareSystem("mysystem2", func() {
Container("mycontainer2", func() {
Uses(container1, "Uses")
})
})
})
```

I would like to be able to write something like the following instead:
```
var _ = Design(func() {
system1 := SoftwareSystem("mysystem1", func() {
})

container1 := system1.AddContainer(Container("mycontainer1", func() {
}))

SoftwareSystem("mysystem2", func() {
Container("mycontainer2", func() {
Uses(container1, "Uses")
})
})
})
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.