INFO PAGE
Object Oriented Programming Theory
Object Oriented Programming or OOP is a metaphor used by most progamming languages. It models life in that things are objects (nouns) with properties (adjectives) and they have methods of doing things (verbs). Let's take a step back and tell a story.
PATTERNS
Just like in real life, patterns are things that repeat. Dots that repeat make a polka dot pattern ;-) When we can make a template we have a pattern - as in a pattern for a dress. In coding it is the same - coding is made up of all sorts of patterns:
- A variable is a pattern for wanting to assign and change a value
- A function is a pattern - for when we want to execute a block of code
- A loop is a pattern - for when we want to repeat code consecutively
LANGUAGE
The object oriented pattern is such an established pattern that we usually consider it as the language as well. It really is like a language on top of a language as it is written on top of the programming basics. Some history...
PROCEDURAL CODING
In the early days of coding we dealt primarily with numbers and strings (text). To this day, in many languages (such as JavaScript) numbers and strings are called primitives ;-). Coding was procedural and went step by step using a goto command to repeat code. We recognized life's patterns as we started modeling (mimicking) life with code. Things in life are divided up into objects with properties and methods to do things. These patterns matched patterns in our main language with nouns, verbs, adjectives, etc.
ABSTRACTION
A main pattern - a meta pattern - is to recognize that there are patterns. The act of recognizing patterns is called Abstraction. So, we made a language in which objects can be made from patterns. The patterns in the language are called CLASSES. A class is the template from which an object is made. The class defines the properties and methods of an object - termed its members. (Methods are stored as properties - so properties will do as well).
INHERITANCE
We also recognize that a class can have sub classes and super classes. Sub and super just mean below and above referencing a hierarchy diagram with node 0 at top. A sub class has all the properties and methods of the base class plus its own. An object made from a class is said to inherit the members of the super class.
COMPOSITION
An object can be composed of properties - a person object is composed of a head, legs, etc. The head, legs, etc. DO NOT inherit from the person as they are not a type of person rather the person is composed of these parts - this is composition, not inheritance. Classification lets us pick what to make and composition lets us make the object out of parts.
COLLECTIONS
- Platform: an all-encompassing system - Microsoft, Apple, Google, Facebook
- Framework: code that helps you build a complete project - React, Angular, ZIM
- Library: code usually with something in common. jQuery, CreateJS
- Module: code that works together with other modules: Easel.js
- Package: classes usually organized by function - display, data, system, ui, utils
- Class: a template for an object with properties and methods
- Function: a block of code that usually has a more singular purpose
- Variable: a container for a value
- Value: sequential characters often with delimited meaning
- Character: a byte
- Byte: 8 Bits
- Bit: 0 or 1
- null
CONCLUSION
Object Oriented Programming was created by very logical people to model life, hence it is very much a philosophy and I treat it as such (Nodism). OOP models life through a mix of classification and composition. Classification describes the types of things there are (this OR that). Composition describes the parts of things (this AND that).