Make code SOLID.
Five design principles, one hands-on tour. Spot the code smell, flip to a refactor, then test your instincts in the quiz.
Start exploringThe acronym
Not rigid laws or a checklist for every class. Use them to reduce coupling and make change safer.
Five principles, your turn
Spot it. Then improve it.
Choose a letter, judge the example, and flip between the design smell and one possible refactor.
Single Responsibility
One reason to change
Keep each class focused on one responsibility, so a change in one concern does not ripple into unrelated behavior.
C# example
Needs a rethink
public class Report
{
public string Generate() => "report";
public void Save(string report) { /* write file */ }
}right or wrong: does this example have a design smell?
Interview warm-up
Can you spot the principle?
A class formats invoices and sends email notifications. What is the likely issue?
Adapted from our SOLID principles in C# interview guide. These are design heuristics, not rules to apply mechanically.