Chapter 8. Elements of object-oriented programming

This chapter covers

  • Defining contracts by using interfaces
  • Implementing a hierarchy of expressions
  • Implementing the adapter pattern
  • Extending behavior with mix-ins
  • Considering alternatives to pure OOP

In this chapter, we will cover the elements of object-oriented programming and see how we can employ them effectively. You are probably familiar with these concepts, as they show up in all object-oriented languages, so we’ll focus more on their use cases.

We’ll start with interfaces and see how we can think of them as contracts. After interfaces, we’ll look at inheritance: we can inherit both data and behavior. An alternative to inheritance is composition. We’ll look at some of the differences ...

Get Programming with Types 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.