Goodbye, Object Oriented Programming

Inheritance, the First Pillar to Fall

Banana Monkey Jungle Problem

Banana Monkey Jungle Solution

The Diamond Problem

Class PoweredDevice {
}
Class Scanner inherits from PoweredDevice {
function start() {
}
}
Class Printer inherits from PoweredDevice {
function start() {
}
}
Class Copier inherits from Scanner, Printer {
}

The Diamond Solution

Class PoweredDevice {
}
Class Scanner inherits from PoweredDevice {
function start() {
}
}
Class Printer inherits from PoweredDevice {
function start() {
}
}
Class Copier {
Scanner scanner
Printer printer
function start() {
printer.start()
}
}

The Fragile Base Class Problem

import java.util.ArrayList;

public class Array
{
private ArrayList<Object> a = new ArrayList<Object>();

public void add(Object element)
{
a.add(element);
}

public void addAll(Object elements[])
{
for (int i = 0; i < elements.length; ++i)
a.add(elements[i]); // this line is going to be changed
}
}
public class ArrayCount extends Array
{
private int count = 0;

@Override
public void add(Object element)
{
super.add(element);
++count;
}

@Override
public void addAll(Object elements[])
{
super.addAll(elements);
count += elements.length;
}
}
  public void addAll(Object elements[])
{
for (int i = 0; i < elements.length; ++i)
add(elements[i]); // this line was changed
}

The Fragile Base Class Solution

The Hierarchy Problem

The Hierarchy Solution

Document
Company
Handbook

Encapsulation, the Second Pillar to Fall

The Reference Problem

The Reference Solution

Polymorphism, the Third Pillar to Fall

Broken Promises

So then what?

--

--

--

Software Engineer and Architect, Teacher, Writer, Filmmaker, Photographer, Artist…

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Simplicity, Clarity, Empathy: A Q + A About Documentation with Hederis’s Nellie McKesson and Erica…

Create a Self-Service Customer Support Chatbot Without Code

GitLab CI/CD for Django on AWS.

5 Reasons your Product needs a Vision

Programming Principles

Bringing Microsoft Media Foundation to GStreamer

Running SQL on Apache Druid — Part I: How to run queries

Loading_data

How to create simple BOT with Amazon Lex

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Charles Scalfani

Charles Scalfani

Software Engineer and Architect, Teacher, Writer, Filmmaker, Photographer, Artist…

More from Medium

The Top 10 Tools For Web Application Development: A Comprehensive Guide — NoCodeAI.Cloud

Functional programming : Avoid Mutations

Troubleshooting the CORS error

Two Heads Are Better Than One: A Pair Programming Conversation