Object-Oriented Programming Principles

Created: 2/26/2017
Updated: 3/6/2017

Introduction

Object-oriented programming principles are intended to help reduce the complexity of code and address the maintainability of software.

Encapsulation

What: The principle of hiding implementation details and restricting access to accessors (e.g. getter-type functions) and mutators (e.g. setter-type functions) to prevent inappropriate usage.
Why: Makes object more safe and easy to use. Ideally, it should not be possible for the object to be in an invalid state.

Abstraction

What: Principle of using a simpler and more essential representation (e.g. abstract class, interface, function).
Why: Allows internal implementation detail to be easily changed out or allows for more code reuse with cleaner code.

Inheritance

What: Principle of reusing characteristics/implementation provided by a base class.
Why: Centralizes and allows for code reuse.

Polymorphism

What: Principle of allowing for dynamic behaviors (or multiple forms) under the same action (e.g. method call).
Why: Centralizes and allows for code reuse.



All content copyright © 2009-2017 Johnny Huynh. All rights reserved.