Richie’s Programming Pocket Book

Abstraction

Hiding away details that do not need to be known. Not of importance how something is done. Examples: 1) A coder makes an IO call but does not care how it’s done underneath. 2) Buttons exposed on a device but inner wiring is hidden by a case.

Composition Over Inheritance

Building business-domain classes by including instances of other classes that implement behavioral functionalities instead of inheriting the behaviors from parent classes. Advantages are flexibility in composition of different types of classes, reuse of behavioral classes, transparency of behaviors in business-domain classes (not hidden in parent classes), and less restructuring when new behaviors are introduced.

Dependency Injection

Instead of declaring concrete dependencies in a class, make the class open to accepting dependencies that should be fed to it through setters or constructor parameters. This adheres to the Inversion of Control principle.

Encapsulation

Combining coherent things in one logical place. Example: Combining data and related methods into a single class, like a Clock class containing current time and methods to change the time.

Inversion of Control

Instead of allowing an entity (e.g. class, application) to declare what it needs, have the underlying framework give the entity what it needs. It mirrors the Hollywood Principle.

Polymorphism

The ability of an object to take on multiple forms. Examples: 1) A Honda Civic is a car, and a car is a vehicle, so a Civic is both a car and a vehicle. 2) A frog is an amphibian, and an amphibian is an animal, so a frog is both an amphibian and an animal.