Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Going back to the 90s, it wasn’t until I read Mark Nelson’s book on STL that object-oriented programming made sense to me. Part of it also was that the people writing books on C++ back then probably didn’t understand OOP either, so most of the books were essentially talking about C, but with different syntax for comments and I/O. With STL, suddenly the whole concept of OO made sense to me.

When I started picking up functional programming later in my career, it was all so much easier for me to grok, largely because it was stuff I’d wanted to do earlier in other languages but didn’t have the capability in the languages I was using to support it.



OOP does not make sense to me. I understand it, I use it when I have to, but things like encapsulation and inheritance don't make sense to me. In my experience they tend to over complicate things, spread state in multiple places so it becomes hard to follow and make the software more brittle.

If null was 1 billion dollars mistake, to paraphrase Tony Hoare, OOP was at least 2 billion dollars mistake.


A lot of confusion comes down to some bad use of inheritance. Probably the most important OO concept is the Liskov Substitution Principal, viz that if you specify a superclass in a certain place, then any subclass should be a valid use there. The strategy pattern (or its hyperpituitary cousin, IoC) takes advantage of this to allow for run-time change of behaviors, e.g., being able to choose through configuration how to serialize a data structure so the same basic logic can output, say, a dataset as a table or a graph. That said, as OO architecture has matured over the last few decades, there has definitely been a tendency to favor composition over inheritance for code flexibility.

I would recommend Head-First Design Patterns as another great book for being able to “get” object-oriented architecture.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: