Chapter 7: Design Patterns and Clean Code

In the previous two chapters, we have been looking at how to write modern, object-oriented, and typed PHP 8 code. That is all well and good, but there is always going to be a difference between writing valid code and writing clean, self-documenting, and easily testable code.

In this chapter, we are going to explore some ways you can move from writing code that works through to code that works and is also a pleasure to work with throughout its life cycle, from initial writing through to long-term maintenance.

This chapter will cover the following main topics:

  • Clean code overview
  • Design patterns

As usual, you can find all the code samples for this chapter in the main repo for the book available on GitHub ...

Get The Art of Modern PHP 8 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.