structurizr / dsl

Structurizr DSL
https://docs.structurizr.com/dsl
Apache License 2.0
1.41k stars 265 forks source link

Variable scope for relationships #236

Closed cnd5041 closed 1 year ago

cnd5041 commented 1 year ago

Description

It'd be nice if variable declarations were hoisted / scoped in a way that order did not matter. I am hoping to keep the relationships close to the containers, but am running into an ordering problem. From what I can tell, if you are going to use a variable, it needs to be declared above the reference. Which, in certain cases with "circular" dependencies between systems is not possible.

Example: This will error that c2 is not defined yet. However, if I re-order, I'll run into the issue of c3 not being defined yet.

system1 = softwareSystem "System 1" {
            c1 = container "Container 1" {
                -> c2 "Uses"
            }
            c3 = container "Container 3"
        }

system2 = softwareSystem "System 2" {
            c2 = container "Container 2" {
                -> c3 "Uses"
            }
        }

I also might be missing a way to do this. Appreciate any help or input.

Priority

Low

Resolution

I have no budget, please add this feature for free

More information

Thank you! Kicking the tires on the tool and it's been solid.

simonbrowndotje commented 1 year ago

The DSL parser processes the source line by line, making calls to the underling Structurizr for Java library to create the workspace as it proceeds through the file ... i.e. it's imperative rather than declarative, so there's no easy way to do what you're asking I'm afraid.

cnd5041 commented 1 year ago

Figured there was going to be some sort of limitation like that, but wanted to ask. Thanks though, having some fun with the tool.