Add content: Law of Demeter in Software Design roadmap

Added comprehensive explanation of Law of Demeter principle with examples. Fixed @article tag capitalization.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ahmed Adel
2025-10-20 11:46:50 +05:00
committed by GitHub
co-authored by Claude
parent dc60c4eb00
commit 4155d2efaf
@@ -1 +1,34 @@
# Law of Demeter
# Law of Demeter
Also called “Principle of Least Knowledge”, it states:
A method should only interact with its immediate dependencies, not deeply nested objects.
## In Practice
- Avoid chaining calls deep into the internals of other objects.
- Restrict communication to objects you directly manage.
### 🔹 ❌ Bad Example (Violation)
```
// Controller
total = order.customer.address.getRegionTaxRate() * order.amount
```
### 🔹 ✅ Good Example
```
// Controller
total = order.calculateTotal()
```
## 🔹 Why It Matters
- **Reduces coupling** → fewer dependencies between classes.
- **Increases maintainability** → changes in one class don’t affect distant classes.
- **Improves readability** → clear boundaries of responsibility.
## 🔹 Resources
- [@Article: Law of Demeter Explained](https://en.wikipedia.org/wiki/Law_of_Demeter)