Inheritance – the myth of code reuse  | Andrei Raifura | CodeWay 2015
Articles Blog

Inheritance – the myth of code reuse | Andrei Raifura | CodeWay 2015


The subject of today’s presentation is inheritance, no matter how trivial and simple it might sound. We’ll talk about how inheritance helps us reuse the code, why sometimes it doesn’t work, and its pitfalls. And at the end we will talk about when we
should and when we shouldn’t use inheritance. Let’s start with understanding inheritance. The majority of you, as I did, the first time
I heard about inheritance was when I started learning about OOP (object-oriented programming), at the university I learned that OOP has 4 basic principles: encapsulation, abstraction, inheritance and polymorphism. Their definitions and particularities.
Here’s the official definition of inheritance I’ve found. Inheritance is a mechanism of reusing the code,
usually in subclasses, via public methods In short, it’s a mechanism for code reuse. We were taught like that: if we have a cat and a dog and if they both have 2 ears, 4 legs and 1 tail, we make a class called “animal”, containing the common things Then we make subclasses, a cat and a dog one, and we tell that one of them woofs and the other meows

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top