So far, you’ve seen structured principles like SOLID and concepts like cohesion and coupling.
But in day-to-day development, you don’t always think in formal principles.
Instead, you rely on simple rules that guide decisions quickly.
Three of the most important ones are:
- DRY (Don’t Repeat Yourself)
- KISS (Keep It Simple)
- YAGNI (You Aren’t Gonna Need It)
These look simple, but they prevent a large number of real-world design issues.
DRY — Don’t Repeat Yourself
Every piece of knowledge should have a single, unambiguous source.
What goes wrong without DRY
You implement pricing logic in multiple places:
- checkout flow
- order summary
- invoice generation
Initially, everything works.
Later:
- tax calculation changes
- discount rules update
Now you must update logic in multiple places.
Miss one, and your system behaves inconsistently.
Applying DRY
Centralize logic:
PriceService:
- calculate_price(order)
Now:
- one source of truth
- consistent behavior across the system
Important nuance
DRY is not just about avoiding duplicate code.
It’s about:
Avoiding duplicate logic and knowledge
Common mistake
Over-applying DRY too early:
- creating generic abstractions
- forcing unrelated logic into one place
This leads to:
- complexity
- harder readability
KISS — Keep It Simple
Prefer simple solutions over complex ones.
What goes wrong without KISS
You design a simple feature using:
- multiple design patterns
- deep abstractions
- unnecessary layers
The system becomes:
- harder to understand
- slower to modify
Applying KISS
Choose the simplest approach that solves the problem.
Sometimes:
- a simple class is enough
- a straightforward condition is fine
Complexity should be introduced only when required.
Important nuance
KISS does not mean:
- writing messy or unstructured code
It means:
Avoiding unnecessary complexity
YAGNI — You Aren’t Gonna Need It
Don’t build functionality until it is actually needed.
What goes wrong without YAGNI
While building an MVP, you add:
- multi-region support
- advanced recommendation system
- dynamic pricing engine
None of these are required immediately.
Result:
- longer development time
- more bugs
- increased complexity
Applying YAGNI
Focus on current requirements:
- build what is needed now
- leave extension points for future
Do not implement features based on assumptions.
Important nuance
YAGNI does not mean:
- ignoring future scalability
It means:
Don’t implement future features without real need
How these three work together
- DRY → keeps logic consistent
- KISS → keeps design simple
- YAGNI → keeps scope controlled
Together, they help you:
- avoid over-engineering
- write maintainable code
- move faster without creating chaos
A practical way to use them
When designing, ask:
- Am I repeating logic? → DRY
- Am I overcomplicating this? → KISS
- Do I really need this right now? → YAGNI
Closing thought
Good design is not just about what you build.
It’s also about what you choose not to build.
Top comments (0)