Chapter 6. Object-oriented principles

6.1 Principles and patterns 103
6.2 The open-closed principle (OCP) 105
6.3 The single-responsibility principle (SRP) 109
6.4 The dependency-inversion principle (DIP) 115
6.5 Layered designs 119
6.6 Summary 122

Once there was a large, heavy, complex web application with lots of modules, bells and whistles, or even timpani and trumpets. It was reasonably successful, but needed to be adapted to a new customer’s needs. The customer needed something with fewer features but with a specific look and feel. The look and feel was well defined: There was an HTML file containing all the styling and layout that was needed.

The existing application had flexibility built in so that a web designer could change the layout ...

Get PHP in Action now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.