PART 1OOP and Patterns

CHAPTER 1Abstract Classes, Interfaces, and Programming by Contract

In this chapter, you will learn about abstract classes, interfaces, and a technique known as programming by contract. These are object-oriented programming (OOP) mechanisms that allow you to write code that does more than just perform calculations or present output. These constructs give you the ability to define conceptual rules about how classes interact, and they provide a foundation for extension and customization in your applications.

Abstract Classes

Abstract classes involve the use of a common base class when you want to leave certain details up to its inheritors—specifically, when you need to create a foundational object whose methods are not fully ...

Get Pro PHP: Patterns, Frameworks, Testing and More 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.