The Backbone of Object-Oriented Programming
Before Object-Oriented Programming, OOP, there was Procedural Programming that divided a program to a set of functions. Data would be stored with variables and functions that operate on the data, but as you would imagine when your program becomes more dynamic this would cause problems. You would find yourself copying and pasting line of code over and over; make a change to one function and others will break. Having too many interdependencies between all these functions is problematic. Also know as “spaghetti code”, this way of coding gave birth to the theory of Object-Oriented Programming.
Alan Kay is generally accepted as being the main pioneer of the concept. While in grad school he was mentor by Ivan Sutherland, from Ivan’s teaching he came up with the theory of programming in object-orientation. Even though he’s credited for the definitive idea of OOP, Alan Kay never wrote a language for it until 1972 when Smalltalk first appeared. He gained his influence from SIMULA when he was developing it, he adopted some of the practices and syntaxes like Classes and Subclasses.
Another pioneer was Ivan Sutherland, in 1963 he published Sketchpad Thesis. Even though his thesis didn’t directly addressed OOP, his other contribution and allusion towards it did. The thesis was compose of Human-Computer Interaction (HCI), Computer-Aided Design (CAD), and computer graphics in general. HCI would later change to the modern-day term User Experience (UX) and Graphical User Interface (GUI) was also derived from it. This was a major breakthrough and pave the way towards the theory of programming in object orientation.
Many sources point to SIMULA as being the first language to implement the concept of OOP. Created by Kristen Nygaard and Ole-Johan Dahl, it first appeared in 1962. It was designed for doing simulations and the needs of that problem domain provided the framework for the features of object-oriented languages today. SIMULA introduced objects, classes, inheritance, subclasses, and virtual procedures.
OOP at its core gives you a better model of how to organize your code. The 4 main cores that defines OOP are:
- Encapsulation, reduce complexity and increase reusability
Grouping related variables and functions that operate on them into objects.
2. Abstraction, reduce complexity and isolate impact of changes
We can hide some of the properties and methods from the outside. Making the interface of those objects simpler, using an object with a few properties and methods is easier. Than an object with several properties and methods
3. Inheritance, eliminate redundant code
Is a mechanism that allows you to eliminate redundant code, we do by defining it once in a generic object. Then having other objects to inherit these properties and methods.
4. Polymorphism, refactor switch/case statements
Is a technique that allows you to get rid of long ethanol’s/switch and case statements. We could implement a render method in each of these objects, and the render method will behave differently depending on the type of the object your referencing.