December 23, 2021

Object-Oriented Programming

  —A book review on the book of the same name.

I recently read the book Object-Oriented Programming, by Brad Cox. It does a really nice job of explaining object-oriented programming and it’s well worth the read.

The main take-away’s I got form the book were:

  • focus on the client-supplier relationship and make the client’s life as simple as you can.
  • use encapsulation to restrict the effect of change.
  • use dynamic binding to ensure extensibility of the system over time.

Two of three of these ideas seem pretty standard now (this is an old book), but the client-supplier relationship really resonated with me. It resonated with me because its a different perspective on interfaces that I think is really hard to get correct. If you use SOLID, for example, there isn’t much guidance what makes a good interface.

When I think of SOLID, I think the interface more explicit in the Open-Closed and the Liskov Substition principles. The other principles encourage encapsulation by are very general.

For example, Single Responsibility (SRP) is a property of a good class but it doesn’t say anything about the class API. Client-supplier complements SRP nicely because it forces you to extend your thinking beyond the responsibility to how the class will be used. And ultimately what the class methods should look like.

The bulk of the book focuses on Object-C and discusses Smalltalk. The explanations of Smalltalk that focus on messages and methods really add emphasis on the importance that messages and methods are actions. It’s a nice reminder to what you are trying to achieve by creating them in the first place.

comments powered by Disqus