P

PrepStack

SOLID Principles

SOLID is a set of five design principles (rules of thumb for how to arrange classes) for object-oriented code: single responsibility, open-closed, Liskov substitution, interface segregation and dependency inversion. Interviewers ask for them to see whether you can build code that is easy to change. According to Wikipedia, Robert C. Martin introduced the basic principles in a 2000 paper and Michael Feathers coined the name SOLID around 2004. Some ideas are older.

After this section you can state each principle in one sentence, show a bad and a fixed Java example for it, and explain what the Square and Rectangle example breaks.

Topics in this section