Design patterns that every developer must know?

16,081

Solution 1

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.

Solution 2

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.

Solution 3

Model–view–controller just has to be on the list, Spring has an MVC framework:

http://en.wikipedia.org/wiki/Model–view–controller

Solution 4

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.

Solution 5

I would recommend you get and read the Design Patterns book, since it gives you the vocabulary.

Share:
16,081
Shaw
Author by

Shaw

Updated on June 11, 2022

Comments

  • Shaw
    Shaw about 2 years

    What are the design patterns that every developer must know?

    I'm interested in the context of Java web developers working with Spring & Hibernate. I have often heard that good knowledge in design patterns is essential for working with those frameworks. Can anyone list the specifics?

    For example, I know that understanding abstract factory & factory pattern, singleton pattern etc is absolutely essential. I'm looking for a comprehensive list.