Bird
Raised Fist0

A class manages both business rules and audit logging. If audit requirements change frequently but business rules are stable, what happens if SRP is not applied?

medium🧠🧾 Concept Trace Q4 of Q15
OOP & Design Patterns - Single Responsibility Principle - One Class, One Reason to Change
A class manages both business rules and audit logging. If audit requirements change frequently but business rules are stable, what happens if SRP is not applied?
AFrequent audit changes will force modifications in business logic code, increasing risk.
BBusiness logic will be unaffected by audit changes due to separation of concerns.
CAudit logging can be changed independently without touching business logic.
DThe class will automatically adapt to audit changes without side effects.
Step-by-Step Solution
Solution:
  1. Step 1: Identify responsibilities

    Business rules and audit logging have different reasons to change.
  2. Step 2: Consequence of combined responsibilities

    Audit changes require edits in the same class, risking unintended effects on business logic.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    Combined responsibilities cause fragile code with ripple effects [OK]
Quick Trick: One reason to change per class prevents ripple changes [OK]
Common Mistakes:
MISTAKES
  • Assuming separation of concerns without SRP enforcement
  • Believing audit changes won't affect business logic
Trap Explanation:
PITFALL
  • Candidates often confuse separation of concerns with SRP enforcement.
Interviewer Note:
CONTEXT
  • Evaluates understanding of SRP's role in isolating change impact.
Master "Single Responsibility Principle - One Class, One Reason to Change" in OOP & Design Patterns

2 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More OOP & Design Patterns Quizzes