Design patterns that every developer must know? Design patterns that every developer must know? spring spring

Design patterns that every developer must know?


Inversion of Control

If you are ever going to design decoupled systems, you will need to know how to properly link dependencies between classes.

Command Pattern and Variants

In Java in particular, it is essential to learn how to pass a piece of functionality to another method as an object because of the lack of closures and function pointers in the language.

Factory Pattern

Factories are ubiquitous in Java frameworks and it is essential to learn why and when to use the factory pattern.

Singleton (pattern and anti-pattern)

Learning how to use the singleton pattern responsibly is very helpful for understanding the pitfalls in other people's code you may be reading.

Overall, learning the why with regards to patterns is much more important the the how. Knowing when not to apply a pattern is just as important as knowing when to.


Everybody should know about Singleton, but also when not to use it! It's currently the source of much pain for me on a project at work.

Singletons make the code hard to understand and follow, and make writing unit tests much more difficult. I like the blog post Singletons are Pathological Liars.


Most design patterns are pretty obvious--you already know and use them if you've been programming a few years.

The biggest advantage I've found to design patterns is sharing a common set of names. If someone says "Callback" that can mean quite a few things, but if someone says "Listener Pattern" that means a more specific set of calls and implies a higher level relationship between objects.

So in essence, read through a good design patterns book, get an idea of the name of each pattern, spend some time understanding any you don't know, and you're good to go.

I wouldn't completely ignore any of them--they are all good to have seen. You should be able to recognize a situation that might benefit from a specific pattern and know where to look to find out more about it.