separation of concerns (SoC)
Separation of concerns, or SoC, is the design principle of dividing a program into distinct sections so that each one addresses a single concern, meaning a single aspect or responsibility of the system.
Note: Edsger Dijkstra coined the term in his 1974 essay On the Role of Scientific Thought, arguing that one should study each aspect of a subject in isolation for the sake of its own consistency.
A concern is anything that motivates a piece of code, from a feature or business rule to a cross-cutting matter like logging, security, or persistence. Keeping concerns apart lets a developer reason about, change, and test one part of a system without having to understand the rest.
The principle shows up at every scale of software design:
- Encapsulation: Hides the internal details of a module behind a stable interface, so its implementation becomes a concern separate from its use.
- Layered architecture: Splits a system into tiers such as presentation, business logic, and data access, each handling its own responsibility.
- Model-View-Controller: Separates data, presentation, and input handling in user interfaces.
- Web technologies: Divide a page into structure with HTML, presentation with CSS, and behavior with JavaScript.
A layered architecture makes the principle concrete:
Closely related ideas include high cohesion, loose coupling, and the single-responsibility principle, which all push a design toward parts that each do one thing well. Poorly drawn boundaries scatter a single concern across many modules and couple unrelated ones together.
Related Resources
Tutorial
SOLID Design Principles: Improve Object-Oriented Code in Python
Learn how to apply SOLID design principles in Python and build maintainable, reusable, and testable object-oriented code.
For additional information on related topics, take a look at the following resources:
- Model-View-Controller (MVC) in Python Web Apps: Explained With Lego (Tutorial)
- Python Application Layouts: A Reference (Tutorial)
- Refactoring Python Applications for Simplicity (Tutorial)
- Object-Oriented Programming (OOP) in Python (Tutorial)
- Python Modules and Packages: An Introduction (Course)
- Design and Guidance: Object-Oriented Programming in Python (Course)
- SOLID Design Principles: Improve Object-Oriented Code in Python (Quiz)
- Model-View-Controller (MVC) in Python Web Apps: Explained With Lego (Quiz)
- Structuring a Python Application (Course)
- Python Application Layouts: A Reference (Quiz)
- A Conceptual Primer on OOP in Python (Course)
- Intro to Object-Oriented Programming (OOP) in Python (Course)
- Object-Oriented Programming (OOP) in Python (Quiz)