Loading...
Loading...
Browse 4 real-world technical and behavioral interview questions about Refactoring. Review scenarios, edge cases, and architectural best practices.
Work out what the test was actually asserting. If it pins behaviour a user depends on, the refactor changed behaviour and the test did its job; if it pins an implementation detail, it never had value and the failure is the cost of having written it that way.
A class violates SRP when it has more than one reason to change, not when it has more than one method; the refactor is to split along the axes that have independently churned, such as pricing rules, persistence, and presentation, and to stop splitting once each piece has its own requester.
Use the strategy pattern instead of inheritance when behaviour varies independently from object identity. Composition avoids subclass explosion, enables runtime swapping and makes algorithms easier to test.
The interface was assembled from the union of what implementations do rather than from what any one caller needs, so no implementation can honour the whole contract. Split it by client into role interfaces, working from the call sites rather than from the classes.