2023-05-06 12:50:39
Each software module should have one reason to change.
In other words...
Where
module = A class, function or method
Make your modules single purpose or responsibility.
Examples of Responsibility
- Persistence
- Logging
- Validation
- Business Logic
Responsibilites change at different times for different reasons.
Tight Coupling
This is when two or more modules are bound together in a way that makes modification difficult.
Loose Coupling
Offers a way to choose which modules are used in a particular operation.
Separation of Concerns
Programs should be separated into distinct sections, each addressing a separate concern or information that affects the program.
Cohesion
Group modules that belong together.
For example CRUD modules.
Key Takeaways
- Modules should have a
single responsibility . - Strive for
high cohesion . - Strive for
loose coupling . - Keep modules
small ,focused andtestable .