Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: make using variables easier #862

Open
yann-soubeyrand opened this issue Feb 14, 2025 · 0 comments
Open

Feature request: make using variables easier #862

yann-soubeyrand opened this issue Feb 14, 2025 · 0 comments

Comments

@yann-soubeyrand
Copy link

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")
		})
	})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant