loading...

re: Practical Coding Patterns For Boss Developers #1: Special Case VIEW POST

FULL DISCUSSION
 

Thank for sharing this James. I've seen this and used this pattern before, but didn't really have a name for it. Thanks for the clarification. I've always thought about it as a part of implementing the factory pattern.

 

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 👍

code of conduct - report abuse