Solid Case Study

Clean Code, Episode 14

By Uncle Bob

43 minSep 2012

OK, this one's a little different. No science lesson. The tone is a bit more serious. (a bit more.) It's the conclusion to the series on the SOLID principles. In this episode we look again at the Payroll Example from Episode 7; but this time we do so in the light of the SOLID principles.

In this episode we start from use cases, and work through each of the principles to create a design. We break up the use cases by using the SRP. We start to build the architecture using the OCP. We find LSP issues to solve in the complex polymorphism hierarchies. We find the ISP lurking in factories. And, of course, the DIP is everywhere.

As we walk through this case study, we examine each principle in depth. We allow the principles to illuminate issues in the design, and then we discuss several ways those issues can be addressed. Bit by bit we piece together the design.

Then we close by taking a lesson from Joel Spolsky when he criticized these principles several years back, without really knowing what they were.

So sharpen your pencils, you're going to need them, because this is an in-depth review and case study of the SOLID principles.