All challenges
Multiple ChoiceBeginner 45s

SRP: finding the second reason to change

A class Invoice totals line items AND formats a PDF AND sends it by email. Which statement best captures the Single Responsibility Principle violation?
Options
  1. 1Three distinct actors (accounting, reporting, mail) can request changes, so the class has more than one reason to change
  2. 2The class exposes three public methods. SRP therefore demands splitting it into three classes. One class per method is the required fix.
  3. 3The class spans too many lines and fields. Its sheer physical size is what violates SRP. The rule is about file length, not reasons to change.
  4. 4SRP requires exactly one public method per class. Every other responsibility must be made private. A second method breaks the principle.

Think you can answer under pressure?

Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.

Play this in a 3-minute battle