A method switches over a type code. Which principles does that break, and how would you fix it?Open/closed, since each new type edits the switch, often SRP too. Polymorphism or a strategy map fixes it, unless the set of types never changes.
Walk me through dependency inversion with a concrete example.The high-level class owns an interface such as OrderRepository, the database class implements it, and a test passes in a fake.
When would you choose not to apply SOLID to a piece of code?Throwaway scripts or a class with one implementation and no second in sight. Add the interface when the second case or the pain shows up.
What you can say
SOLID is five design rules that keep code easy to change, test and reuse, and each letter is named after a pain teams have felt.
Single responsibility means a class has one reason to change. Open/closed means you add behaviour without editing code that already works.
Liskov substitution says a subtype has to work anywhere its base type does, and interface segregation says small contracts beat one fat contract.
Dependency inversion means high-level code depends on abstractions rather than concrete classes, so the logic can run without a real database.
Teams bother because they've hit the pains, like one change spread across five files, an if chain that grows with every feature, or a subclass that throws from an inherited method.
The limit is that applied blindly, SOLID gives you a class per line of logic, so I reach for a letter when I can name the pain it fixes.
Weak answers to avoid
Recites the five names and stopsThe question also asks why teams bother. Tie each letter to the pain it prevents, such as an if chain that grows with every new feature.
Says SRP means a class does one thingThe rule is one reason to change. A class with several methods that all change for the same reason is fine, so split by reason to change, not method count.
Treats DIP and dependency injection as one thingDIP is about the direction of dependencies, toward abstractions. Injection is one way to hand those in. Blurring them sounds like you know the tool but not the rule.
Sells SOLID as always goodBlind use gives you a class per line of logic. Show judgement by saying when you'd hold back, like a class with one implementation and no second one coming.
Interview lens
Likely follow-ups, what you can say, and the weak answers to avoid.