Single Responsibility Principle

A class should have one job, and so only one reason to change.

What is Single Responsibility Principle?

The Single Responsibility Principle says a class should have one job, so it has only one reason to change. A class that calculates payroll should not also format the PDF report.

// Split one big class into focused ones
public class PayrollCalculator { /* works out pay */ }
public class PayslipPdfWriter  { /* turns pay into a PDF */ }

Level: Freelancer · More OOP terms at this level

Updated