🗂️ Software Design Principles · Core Principles
Separation of Concerns
Different kinds of work should be separated.
Keep presentation, business rules, data access, and integrations distinct.
The web page collects input; a service validates it; a repository saves it.
💡 Like a restaurant: the waiter takes your order, the chef cooks, the cashier handles money — one person doing all three means chaos.
💡 Why it matters
When screen code, business rules and database code are tangled together, you cannot change one without risking the others. Keeping layers separate lets you swap the database, redesign the page, or test the rules on their own. It makes a large system understandable one layer at a time.
🛠️ How to achieve it
⚠️ Signs of trouble
- •Business rules are written inside page or button-click code.
- •A database query sits in the middle of the screen layout.
- •Changing the database forces changes across the whole app.
- •You cannot test the rules without starting the user interface.
🎯 Quick check
Score: 0/3Three questions to test the idea.
1. Where should business rules like pricing live?
Answer: In a service layer, not in the screen code
Rules belong in their own layer so they can be tested and changed without touching the screen.
2. Why wrap the database behind its own layer?
Answer: So the rest of the app does not depend on its details
Isolating data access lets you change or swap the database without rewriting the whole app.
3. What is a symptom of poor separation of concerns?
Answer: SQL queries mixed into screen layout code
Database code sitting inside the presentation is a classic sign the concerns are tangled.
