I agree, there just seems to be a natural connection between this pattern and the factory pattern since you need something to decide how to instantiate the classes.
Usually, the pattern is for avoiding null issues, but I really like the idea of being intentional about splitting classes up more semantically instead of having internal variables that hint that the object is in a very specific or special state.
I've used the pattern when building viewModels too, for example. Each variant can each format themselves totally differently 👍
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You're welcome 🤜🤛
I agree, there just seems to be a natural connection between this pattern and the factory pattern since you need something to decide how to instantiate the classes.
Usually, the pattern is for avoiding
null
issues, but I really like the idea of being intentional about splitting classes up more semantically instead of having internal variables that hint that the object is in a very specific or special state.I've used the pattern when building viewModels too, for example. Each variant can each format themselves totally differently 👍