What is the most underused or underappreciated design pattern?
design-patterns
Solution
Most important "patterns" for a newbie is to
- keep it simple.
- Learn why supposedly good practices are good, so you can tell if they are good for the particular situation.
- You have to balance competing concerns for a situation, not just think about one. (decoupling v. cohesion, testing soundness v. completeness, good practices v. time)
As far as formal patterns with cool names go, I think reviewing patterns that focus on interfaces are helpful, because help get you thinking in terms of dependency and contracts, rather than just objects. Or as Uncle Bob (Martin) says, Depend on abstractions, not on concretions. So my answer is:
- Dependency Injection
- (to a lesser extent facade, decorator, adapter)
See Dependency Inversion Principal, one of the SOLID Principals, (which I'm sure you've already analyzed). Looked at narrowly, DI is very simple though it's often made over-complicated. I believe it's important to also look at it in a wider context, a way of thinking about every level and part of your design, not just code arranged in a certain way.
A small word of warning. I think some pattern-newbies become over-zealous with patterns and don't think code is good unless it's implementing a pattern, and that a pattern makes a solution good. They sometimes focus on patterns to the detriment of other good OOP/D practices. This is a mistake. Mr. Solid himself explains this here.
Problem
I have been reading a lot on design patterns lately and some of them can make our lives much easier and some of them seem to just complicate things (at least to me they do). I am curious to know what design patterns everyone sees as underunsed or underappreciated. Some patterns are simple and many people do not even realize they are using a pattern (decorator probably being the most used, without realized). My goal from this is to give us pattern-newbies some appreciation for some of the more complex or unknown patterns and why we should use them.