Skip to content

Feature request: make using variables easier #862

@yann-soubeyrand

Description

@yann-soubeyrand

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")
		})
	})
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions