structurizr / dsl

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

Why are "names" of Components or other types unique, when we have identifiers? #102

Closed andygrunwald closed 2 years ago

andygrunwald commented 2 years ago

Hey,

i am playing around with the DSL and the diagram as a code 2.0 model.

I wonder why are names of components or components requires to be unique? From what I can see, the names are used for display purposes. The identifiers are mainly used for relations.

Consider this example:

workspace {
    model {
        softwareSystem = softwareSystem "Software System" {
            rabbitmq1 = container "RabbitMQ" {}
            rabbitmq2 = container "RabbitMQ" {}
        }
        rabbitmq1 -> rabbitmq2 "talks to each other"
    }

    views {
        theme default
    }
}

This throws an error:

A container named 'RabbitMQ' already exists for this software system at line 5: rabbitmq2 = container "RabbitMQ" {}

When I change rabbitmq2 = container "RabbitMQ" {} to rabbitmq2 = container "RabbitMQ other name" {}

it works as expected and produces this diagram:

Screen Shot 2022-01-06 at 17 18 47

Tested on https://structurizr.com/dsl

I was not able to find any docs about it. Do I miss them? I wonder what are the rationals behind this or if there is a use case that I miss.

Thanks for your feedback!

simonbrowndotje commented 2 years ago

I've added some information about these rules to the language reference ... names need to be unique for things like the layout merging algorithm though.

andygrunwald commented 2 years ago

Got it. Thanks a lot for the context + the fast reply.