Inheritance Tax In Software Development
Topic | Source |
---|---|
๐ฅ๏ธ Tech | The Pragmatic Programmer |
Inheritance tax is a term that describes the problem of strong coupling introduced by inheritance. There are alternatives that create less coupling. For example, using interfaces and implementing those instead. However, this would mean that we have a lot of code duplication, and cannot keep our code dry. To get around this, you can use mix-ins. They are a way to put some additional functionality upon another type or class. You basically create a class of the interface and put the functionality of the mix-in on top. This top-to-bottom approach keeps the code much more decoupled compared to the bottom-up approach of inheritance.