Get the latest tech news

Inheritance and Subtyping


Java is the first language I learned in my career. Its structure is foundational in my early years of understanding programming concepts. After going through several other languages with very different approaches, I’ve widened my point of view. Today, I want to reflect on the idea of inheritance. Inheritance in Java In Java, the idea of inheritance is tightly coupled with the concept of subtyping. Subtyping is the implementation of a IS A relationship. For example, the Rabbit class is a

The problem with this duck typing approach is that it works only for Python’s predefined magic methods. Enter PEP 544, titled Protocols: Structural subtyping (static duck typing). The PEP solves the impossibility of defining magic methods for our classes.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of inheritance

inheritance

Related news:

News photo

Liskov Substitution: The real meaning of inheritance

News photo

How can you represent inheritance in a database? (2010)

News photo

If Inheritance is so bad, why does everyone use it?