Wednesday, November 7, 2018

Design Patterns Questions

Two people standing next to one another. The first says "How do I know if this is the right pattern?" The second says "All that matters is WHAT'S IN YOUR HEART". In large, red letters the word "wrong" sits between them with an arrow pointing to the second guy.

Like code qualities, I'm going to start sharing questions you can ask yourself to help sort through which design pattern applies where.

As I add questions to the set, I expect it to grow into a checklist someone can use to evaluate whether the pattern they are considering is the right one for their situation.

I'm not expecting to create a perfect result every time. I'm happy with better results some of the time.

There will be two categories of question: general and specific.

General questions apply to every pattern. For instance "What variation does this let me add without changing any existing code?" applies regardless of what pattern you are considering.

Specific questions apply to one pattern or a small group of patterns. For instance "Do I need to decouple when something happens from when the decision is made that it should happen?" applies primarily to the Command pattern.

The label for this post will also be on all such questions.