Mid SOLID

How can you identify violations of SRP in code?

You can identify SRP violations by asking questions like:

  • Does this class perform more than one function (e.g., data access and business

logic)?

  • Does it change for different reasons (e.g., changes in UI and database)?
  • Does it have too many dependencies or too much code?
  • Are there “and”s in the class name or method descriptions? E.g.,

ReportGeneratorAndPrinter.

Common signs:

  • Long classes or large files
  • Many unrelated methods
  • Hard-to-test code

More from Design Patterns in C#

All questions for this course