Imagine you are building software for ten years.
You design:
- Payment systems
- Notification systems
- Inventory systems
- Banking systems
- Messaging systems
- E-commerce systems
After a while, you start noticing something interesting.
The problems are different.
But the solution often look similar.
Example:
You need:
One object shared globallyYou solve it.
Years later:
Different project.
Same problem.
Same solution.
Again:
Different project.
Same problem
Same solution.
Eventually software engineers realized:
Many design problems repeat.And many good solutions repeat.
These recurring solutions became known as: Design Patterns
Historical Background
The idea of patterns did not originate in software.
It came from architecture.
Architect: Christopher Alexander
observed that successful buildings often reused similar design solutions.
Example:
A town square
A courtyard
A garden
A window arrangementDifferent buildings.
Same design ideas.
He documented these recurring solutions in:
A Pattern Language
Software engineers later realized:
Software design has recurring solutions too.
This led to the famous book:
Design Patterns
written by:
- Erich Gamma
- Richard Helm
- Ralph Johnson
- John Vlissides
Published in 1994.
This book changed software engineering forever.
What Is a Design Pattern?
A design pattern is:
A proven, reusable solution to a recurring design problem in a specific context.
Notice:
It is NOT:
Reusable CodeIt is:
Reusable DesignPattern vs Code
Suppose you learn:
Factory PatternThere is no single Factory code.
Instead:
The pattern described:
Problem
Context
Participants
Interactions
Trade-offsYou implement it differently every time.
Just like:
Recipeis not:
Finished FoodReal-World Analogy
Imagine traffic lights.
Problem:
Vehicles Need to CoordinateSolution:
Traffic SignalThis solution works in:
- Delhi
- London
- New York
Different cities.
Same pattern.
Leave a comment
Your email address will not be published. Required fields are marked *
