# Inheritance gone wrong

DevFeed: [Inheritance gone wrong](<https://devfeed.tech/articles/inheritance-gone-wrong-27277.md>)

Original publisher: [Read original article](<https://blog.pchudzik.com/201708/inheritance-gone-wrong/>)

Published: 2017-08-15T00:00:00Z

Content type: tutorial

Language: en

Sources: [Paweł Chudzik](<https://devfeed.tech/sources/pawe-chudzik.md>)

Topics: [Inheritance](<https://devfeed.tech/topics/inheritance.md>), [Java](<https://devfeed.tech/topics/java.md>), [coding](<https://devfeed.tech/topics/coding.md>), [implementation](<https://devfeed.tech/topics/implementation.md>), [Polymorphism](<https://devfeed.tech/topics/polymorphism.md>)

Tags: [class](<https://devfeed.tech/tags/class.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [inheritance](<https://devfeed.tech/tags/inheritance.md>), [intellij-idea](<https://devfeed.tech/tags/intellij-idea.md>), [interface](<https://devfeed.tech/tags/interface.md>), [java](<https://devfeed.tech/tags/java.md>)

## AI overview

The article explains how inheritance can expose inappropriate operations through a class hierarchy, using Java's Stack and Vector as an example. It recommends delegation or depending on behavior through interfaces to keep implementations encapsulated and easier to change.

## Source excerpt

We all know how inheritance works and implemented some kind of class hierarchy at least few times during our career. Some of us know already that inheritance is not the silver bullet. Some of us know that inheritance must not be overused and considered with caution. Now I'm going to show you how choosing the quick win might cost you some unexpected troubles in the future. Read more