[Proof of concept] Component isolation #231
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
dry-system provides a nice container for creating new instances of classes, but it doesn't enforce its use. Developers are free to create an object by calling its constant constructor (e.g.
Foo.new
)...until now... 馃槺
With this proposed 'isolation' feature, a component's constant would be removed right after it's loaded, so the users would not be able to call
Foo.new
. Or callFoo
at all. That is, they would have to use the container to create new instances.This may be a very bad idea... it may be going too far. It may have negative unintended consequences. I could see it being useful in some circumstances though. The idea is to remove more global state, by having fewer constants.
This is clearly just a proof of concept. It could be a post-1.0 feature, too. If we wanted to implement this for real, some things (among more, I'm sure) we'd have to consider:
Loader
? i.e. provided as a subclass of Loader, either in this gem or as an external one