DEV Community

[Comment from a deleted post]
Collapse
 
aghost7 profile image
Jonathan Boudreau • Edited

Before we continue, this is NOT an argument for or against using global configuration. As some of us know, global state gets a really bad rap. Just ask around on Software Engineering Stack Exchange.

Global configurations are not state if you make them immutable, which is usually a sensible idea. From what I'm understanding I think what you might want to do is have a builder for the configuration but after the actual configuration is instantiated it is no longer mutable.

Collapse
 
ope profile image
Ope Adeyomoye

Thanks Jonathan,

Immutable configurations are a popular solution too. But in this case, I needed a way to allow the global configuration change if need be, but it had to absolutely deliberate; not via "side-effects".

You usually can't have that with totally immutable objects; they tend to stay unchanged.