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

Constants in DSL can be defined multiple times #253

Closed
GuillaumeTaffin opened this issue Feb 24, 2024 · 2 comments
Closed

Constants in DSL can be defined multiple times #253

GuillaumeTaffin opened this issue Feb 24, 2024 · 2 comments
Labels

Comments

@GuillaumeTaffin
Copy link
Contributor

GuillaumeTaffin commented Feb 24, 2024

Description

A constant defined with the !constant keyword can be overridden, hence is not constants anymore.
This is quite error prone since it allows to easily redefine a constant value in another file (while using includes).

If it is expected behavior, it would probably be interesting to be able to parametrize it to make it stricter (I did not find a way to do it)

Steps to reproduce

  1. Render the snippet in https://structurizr.com/dsl
workspace {
    !constant MICHEL "michel"
    !constant MICHEL "mimich"


    model {
    
        user = person ${MICHEL}
        softwareSystem = softwareSystem "Software System" {
            webapp = container "Web Application" {
                user -> this "Uses"
            }
            container "Database" {
                webapp -> this "Reads from and writes to"
            }
        }
    }

    views {
        systemContext softwareSystem {
            include *
            autolayout lr
        }
    }
}
  1. The second value of the constant MICHEL overrides the first one without issue.

Screenshot

No response

Code sample

No response

Configuration

No response

Severity

Minor

Priority

I have no budget and there's no rush, please fix this for free

More information

No response

@simonbrowndotje
Copy link
Contributor

Thanks, yes, this is a known issue that's been taken advantage of over the years, so requires more than just fixing it. I'm planning on deprecating !constant (removing it in v3.0.0) and replacing it with something like !const and !var.

simonbrowndotje pushed a commit that referenced this issue Feb 24, 2024
@GuillaumeTaffin
Copy link
Contributor Author

GuillaumeTaffin commented Feb 24, 2024

@simonbrowndotje
Do you think it would be useful to pass some property - or something else - to the workspace to parametrize this behavior ?

If yes, if you have a suggestion relative to the DSL part of it I would happily suggest a solution that would better fit what you've in mind.

Or maybe you think that this is not worth adding stuff to the DSL until the deprecation of the !constant ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants