One thing that helped me think about objects properly was writing automated tests, but specifically the discipline of Test-First Development.

What I found, when I wrote the tests first, was that I suddenly was able to really understand the concept of encapsulation. Because when you write the test first, you have to treat the object as a 'black box'. You have to treat it as a black box because when you write tests first, there's literally no code inside the object to test.

Test-First Development was like a lightning bolt of inspiration for me, in terms of understanding APIs and the value of interfaces. It gave me a better understanding of software architecture than I had had before that point.

Expand full comment