DEV Community


Discussion on: Practical Coding Patterns For Boss Developers #1: Special Case

jamesmh profile image
James Hickey Author

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 👍