Member-only story
Imagine coming across the same problem multiple times and having to re-develop a solution for it every time. That would be exhausting, it may even be confusing for those around you and your solution would never get the chance to be optimised. Instead, we use patterns to solve problems. In everyday life we call these heuristics, in software development we call them design patterns.
The design patterns in this post have examples in this repository: https://github.com/tomanagle/JavaScript-design-patterns
Please submit pull requests if you would like to add a pattern or make a change to an existing pattern.
In software development, a design pattern is a solution to a commonly occurring problem that is generally agreed on as the best solution. Understanding design patterns will:
- Make solving recurring problems easier and faster
- Allow you to solve problems with a pre-optimised solutions
- Write code that is familiar to those that understand the design pattern
Creational
Constructor pattern
Problem: I need a way to create a new instance of an object so I can extend its functionality