Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Composition, Inheritance, and Liskov Substitution Principle (joaojunior.org)
3 points by johnjr on April 22, 2025 | hide | past | favorite | 3 comments


In software development, organizing our codebase in a way that is easy to maintain is always a good practice, and this idea is not new. Actually, I think this started in 1968 when the term software crisis was coined. Since then, we have developed many principles to help us achieve this goal. One person who has made many contributions to this field is Barbara Liskov. She is very famous for the Liskov Substitution Principle (LSP), but she also invented the Abstract Data Type(ADT), which is the core concept of classes and object-oriented programming. Here, I want to discuss composition compared to inheritance and how understanding the Liskov Substitution Principle can help you develop better software.


Coincidentally, I just taught composition over inheritance this morning in my class on object-oriented programming in C++ at Ohlone College in Fremont, CA, and gave an example of why it is undesirable for a stack implementation to inherit a linked list as opposed to just having a linked list as a member. We will learn the SOLID principles of object-oriented software design on Thursday. I may end up passing along this article to my students. Thanks for sharing!


Hi @linguae, The video in the post, originally presented by Barbara Liskov, is a very interesting resource on this topic. Let me know if your students want to discuss this in more detail, and please share their ideas!




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: