Bird
Raised Fist0

After splitting a legacy class that combined order processing and audit logging into two separate classes following SRP, what is a critical next step to maintain system integrity?

hard🔁 Follow Up Q10 of Q15
OOP & Design Patterns - Single Responsibility Principle - One Class, One Reason to Change
After splitting a legacy class that combined order processing and audit logging into two separate classes following SRP, what is a critical next step to maintain system integrity?
ARemove all logging to simplify the system.
BMerge the classes back if performance degrades.
CEnsure the new classes communicate correctly to preserve original behavior.
DIgnore integration tests since responsibilities are separated.
Step-by-Step Solution
Solution:
  1. Step 1: Recognize separation

    Order processing and logging are now in separate classes.
  2. Step 2: Identify integration need

    They must interact properly to maintain original system behavior.
  3. Step 3: Critical follow-up

    Verify communication and integration through testing and design review.
  4. Final Answer:

    Option C -> Option C
  5. Quick Check:

    Separated classes must still work together [OK]
Quick Trick: Separated classes need proper integration [OK]
Common Mistakes:
MISTAKES
  • Thinking merging classes back is best after refactoring
  • Assuming logging can be removed without impact
  • Ignoring integration tests post-refactor
Trap Explanation:
PITFALL
  • Option B seems practical but ignores SRP benefits; Option D risks system failures.
Interviewer Note:
CONTEXT
  • Tests understanding of post-refactoring integration and system correctness.
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