Object Oriented Programming

Object Oriented Programming (or OOP) as this article interpretes the term, is a method of reducing coupling between various sets of data and execution by breaking apart an application into several discreete classes and object sets — a method for reducing program mantinence costs. There are many (conflicting, vauge, useless, or just plain different) alternate definitions of this term, this article focuses on this definition.



The particular definition of OOP we've chosen here isn't necessairly synonymous with classes. Classes are a means to implement OOP, but not all uses are equivilant. This article assumes basic knowledge of your language's class system, and will focus on constrasting OOP to non-OOP.

In a nutshell

For this defintion of OOP, we have two main judgement criteria:

1) Encapsulation. In other words, how well does the interface hide the details of how something's been implemented. A generic io device interface that exposes an OS file handle isn't well encapsulated — it isn't portable outside the OS, or to devices not directly handled through the OS's file handle interface. (If we were writing an OS specific File Handle interface wrapper, though, this would be perfectly reasonable to expose if useful).

2) Scope of access. In other words, where are the variables that are depended upon. On one hand, you have dependance on only immeidate class-local/function-argument variables — very OOP. Then you have class-local/function-argument references to other objects (still highly encapsulated/insular — not many dependancies which will break this code if changed). On the farther side of the equasion, you have many levels of indirect access (foo->bar(42)->baz("pineapple")->get(chichiwawa)->set_name( "Senor Dogwaffle" );), and at the farthest reach, globals and singletons (application-wide variables) — both of which are not very OOP. Instead, these are brittle, have a larger possible code base at blame/fault for erronous situations, and are more likely to require refactoring when making changes in an arbitrary part of the program.


Dependency Injection