Single Responsibility Principle (SRP)

The Single Responsibility Principle (SRP) states that every module, class, or function should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirely encapsulated by the class.

Bad Example:

A `Report` class has methods to generate a report and to print the report. This violates the SRP because the class has two reasons to change: the report generation logic might change, and the report printing logic might change.

                
                class Report {
                    public string GenerateReport() {
                        // Logic to generate the report.
                    }

                    public void PrintReport() {
                        // Logic to print the report.
                    }
                }
                
                

Corrected Example:

A better design would be to separate these responsibilities into two classes.

                
                class ReportGenerator {
                    public string GenerateReport() {
                        // Logic to generate the report.
                    }
                }

                class ReportPrinter {
                    public void PrintReport(string report) {
                        // Logic to print the report.
                    }
                }