I was involved in a discussion with another developer and the topic of patterns came up. To quote Addy Osmani:
Design patterns...provide us a common vocabulary to describe solutions.
var variable = variable == undefined ? 'value' : variable;
var variable = variable || 'value';
variable || 'value' will return
variable is true, otherwise it defaults to
'value'. A developer coming later would instantly recognize that pattern and understand that it is only assigning a default value to an undefined variable.
It is also true that a developer that is well versed in the library of patterns will spend less time considering solutions. Instead of spending time thinking about forming the code to solve the problem, the pattern can be written very quickly, almost as though coming from muscle memory!
From the simple to the advanced
- Module pattern
- Revealing module pattern
- Observer pattern
- Mediator pattern
- etc, etc, etc
All of these patterns help to solve common programming problems, while also making your code much more familar and readable to developers coming after you.
Addy isn't the only one of course to have written about patterns and a simple Google search will reveal several pages of results, the number being an indication of just how important this topic is to learn.