Constants in DSL can be defined multiple times
GuillaumeTaffin opened this issue · comments
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
- 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
}
}
}
- 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
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
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
?