Skip navigation.
Home
Software made simple

OO 101

Post contains elementary object oriented programming information.

Do The Simplest Thing That Could Possibly Work

I was reading these posters and the one on simplicity made me think. It brilliantly summarized it with a simple concept: do the simplest thing, not the simplistic one. But what is the difference?

Rules of Simplicity:

  1. Runs all the tests
  2. Says everything once and only once (DRY)
  3. Expresses all the ideas you want to express
  4. Minimizes classes and methods

Why You Should Program To Interfaces Part I

The Open Closed Principle (OCP)

The Open Closed Principle (OCP) states that a system should be open to extension and closed to modification. In other words, it should be easy to add new functionality by not changing existing code. If you program to interfaces, it is much easier to follow the OCP.

Calculator No OCP

Let's build a very simple calculator.

class Calculator {
  int add(int x, int y) {
    return x + y;
  }
}
Syndicate content