Single responsibility principle
The single responsibility principle is a software design principle that gives each component one focused responsibility and one primary reason to change.
Grokking Software Architecture
The single responsibility principle is the design principle that a software unit should have one clearly focused responsibility and one primary reason to change.
- How it is used
- Uses SRP to guide maintainable refactoring and keep independently changing concerns focused.
- How deep it goes
- Explains the one-reason-to-change rule and demonstrates before-and-after refactoring, including focused services and a workflow coordinator.
- Examples
- Uses a shopping cart, a soccer player, and order processing to illustrate responsibilities and refactoring.
- What you can do after
- Practice identifying SRP violations and refactoring multi-job code into focused units.
Read how Grokking Software Architecture explains single responsibility principle →
Software Design for Python Programmers
The Single Responsibility Principle states that a class should have one primary responsibility and remain cohesive around it.
- How it is used
- Organizes classes so each has one primary responsibility and remains easy to use and maintain.
- How deep it goes
- Defines cohesion and demonstrates responsibility allocation, while deferring broader design tradeoffs to iterative development.
- Examples
- Uses Python Book and Catalogue classes, catalogue searches, wildcard-like empty attributes, and concrete search output.
- What you can do after
- Evaluate class designs by identifying whether their data and methods serve one clear primary purpose.
Read how Software Design for Python Programmers explains single responsibility principle →
The Art of Code
The Single Responsibility Principle is an object-oriented design principle stating that a class should have only one reason to change.
- How it is used
- Guides method and class decomposition toward maintainable code with a clear, readable story.
- How deep it goes
- Defines the principle and develops practical boundaries, but stops short of prescribing a universal responsibility size.
- Examples
- Uses method length, single-field validation, user registration, dense eligibility conditions, and deeply nested permission logic.
- What you can do after
- Apply SRP through judgment by splitting code when responsibility, length, or cognitive complexity obscures its story.
Read how The Art of Code explains single responsibility principle →
Object-Oriented Software Design in C++
A design principle stating that a class should have one major responsibility.
- How it is used
- Guides class design during iterative design, coding, and testing.
- How deep it goes
- Defines cohesion and demonstrates it with Book and Catalogue, while cautioning against unnecessary class proliferation.
- Examples
- Uses an overloaded automobile class and a tested Book–Catalogue search application.
- What you can do after
- Build cohesive C++ classes, separate responsibilities, and test their behavior through small application iterations.
Read how Object-Oriented Software Design in C++ explains single responsibility principle →
.NET MAUI in Action
The single-responsibility principle is a software design principle stating that a component should have one primary reason to change.
- How it is used
- Organizes .NET MAUI applications by separating UI, presentation logic, and business logic.
- How deep it goes
- Defines one-purpose classes and methods, then works through responsibility boundaries and their maintenance and testing effects.
- Examples
- Uses MauiStockTake, a car database application, injected services, bound properties, commands, and UI-versus-business-logic comparisons.
- What you can do after
- Apply it via MVVM to separate UI state and behavior from business operations, improving maintainability and testability.
Read how .NET MAUI in Action explains single responsibility principle →
Unit Testing Principles, Practices, and Patterns
The Single Responsibility Principle states that a class or module should have one responsibility and one reason to change.
- How it is used
- Guides refactoring toward testable units by separating business logic from orchestration and external communication.
- How deep it goes
- Explains responsibility separation through dependency examples, Humble Objects, and code depth versus width, without prescribing exhaustive design rules.
- Examples
- Uses concrete-class mocking, difficult dependencies, extracted logic, functional cores, domain layers, controllers, and presenters as examples.
- What you can do after
- Refactor mixed classes into focused domain logic and simpler orchestration components that are easier to test.
Read how Unit Testing Principles, Practices, and Patterns explains single responsibility principle →
ASP.NET Core in Action, 3e
The single-responsibility principle is a design principle stating that a class should have responsibility for one piece of functionality and change only when that functionality changes.
- How it is used
- Combines focused services into a complete application while keeping each class centered on one responsibility.
- How deep it goes
- Explains the definition, applies it to e-commerce services, and connects it to dependency construction without detailing implementation registration.
- Examples
- Uses TaxCalculator, ShippingCostService, and OrderTotalCalculator in an e-commerce order calculation.
- What you can do after
- Apply SRP by separating tax, shipping, and order-total responsibilities into focused services.
Read how ASP.NET Core in Action, 3e explains single responsibility principle →
GitHub Actions in Action: Continuous integration and delivery for DevOps
The single responsibility principle is a software design principle stating that a component should have one primary responsibility and one reason to change.
- How it is used
- Guides the design of focused GitHub Actions and workflow files that remain easier to maintain, review, and audit.
- How deep it goes
- Explains practical boundaries for actions, workflows, and jobs, while treating the principle as guidance rather than an absolute rule.
- Examples
- Uses focused shared actions, purpose-specific workflow files, machine-distributed jobs, development-cycle events, and production-review boundaries.
- What you can do after
- Apply it via GitHub Actions by dividing automation into focused actions, workflows, and justified jobs.
Also covered in
- Machine Learning Platform Engineering
- Spring AI in Action
- The Well-Grounded Python Developer: How the pros use Python and Flask
- Simple Object-Oriented Design: Create clean, maintainable applications
- Rust Servers, Services, and Apps
- Python Concurrency with asyncio
- CSS in Depth, Second Edition
- Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform
- Learn AI Data EngineeringIn early access (MEAP)
- .NET in Action, Second Edition
- Clean Applications with Hexagonal ArchitectureIn early access (MEAP)
What to know first
- methodA method is a callable function or operation associated with a type, class, or object and invoked through that association.
- object-oriented programmingObject-oriented programming is a programming paradigm that organizes software around objects combining state and behavior, often using encapsulation, classes, inheritance, or polymorphism.
- classA class is a programming-language construct that defines a type’s structure and behavior and provides a basis for creating or representing objects.
- interfaceAn interface is a contract or boundary that specifies the operations, members, or data shape a type or component exposes, without prescribing its complete implementation.
Related concepts
- principlekind of · A principle is a general rule, guideline, or value that guides decisions, behavior, or judgments.
- cohesive classimplemented by · A class whose methods and instance variables collectively serve one closely related primary responsibility.
- SOLID principleskind of · The SOLID principles are five object-oriented software design guidelines concerning responsibility, extensibility, substitutability, interface design, and dependency direction.
- functionconfigures · A function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- microserviceimplemented by · A microservice is an independently deployable service that implements a focused business or technical capability within a larger application or distributed system.
Questions about single responsibility principle
What is single responsibility principle?
The single responsibility principle is a software design principle that gives each component one focused responsibility and one primary reason to change.
Which Manning books explain single responsibility principle?
Grokking Software Architecture, Software Design for Python Programmers, The Art of Code, Object-Oriented Software Design in C++, .NET MAUI in Action, Unit Testing Principles, Practices, and Patterns, ASP.NET Core in Action, 3e and GitHub Actions in Action: Continuous integration and delivery for DevOps.
What should I know before learning single responsibility principle?
Manning books that teach single responsibility principle usually introduce method, object-oriented programming, class and interface first.
What is the difference between single responsibility principle and code tangling?
The single responsibility principle is a software design principle that gives each component one focused responsibility and one primary reason to change. Code tangling is an anti-pattern in which logic for separate concerns is intertwined within the same code unit.
What is single responsibility principle a kind of?
Single responsibility principle is a kind of principle. A principle is a general rule, guideline, or value that guides decisions, behavior, or judgments.
What is single responsibility principle also called?
Single responsibility principle is also called SRP.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.







