Facts, Thoughts and Opinions

Inheriting a Class is a Bad Idea

Inheriting a non-abstract class is a bad idea because by overriding a method, we risk breaking the logic of the entire parent class. You probably have no or incomplete knowledge of how the rest of the class uses the method that you are overriding. To extend a final class, treat it like a black box and decorate it with your own implementation.

Virtues of a Good Object

  • It represents something that exists in real-life.
  • It works by contracts (which are represented by the interfaces that it implements).
  • It is unique.
  • It is immutable.
  • Its class doesn't have anything static.
  • Its name tells us what it is, not what it does.
  • Its class is either final (can't be extended via inheritance) or abstract (incomplete and uninstantiatable).


  •   Subtopics

  •   Writings

  Sources & Bookmarks

Name/Link Date