MIC102G » Bonus Materials

Update: March 17th, 2009

Object-oriented Paradigm

Object-oriented programming is a system for organizing code in a logical, real-life way. The object in object-oriented refers to a block of code that represents a more tangible abstraction of data. For example, a program to manage a library would have several objects to represent that library and it's capabilities. One object might be a book, which can be checked out or checked in. Another object might be the librarian who can allow certain people in the library and deny access to other people. The actions that each object can take are methods of the object. A method is a function that belongs to an object.

Pillars of Object-oriented Programming


Encapsulation can be summed up as the black-box concept. You don't have to know what's in it to know that when you put some data in it, it will do it's job. This concept also allows us to accomplish data hiding, which the ability to create variables, methods and store data within the black box but not allow access to that information to something outside of the box. In an object-oriented language, the black box is called a 'class'.

Inheritance and Reuse

When building a new model of car, a manufacturer doesn't start from scratch. They reuse concepts that they built previously. A model 240 might be based on the model 140. The model 240 may look a lot like the 140 but it has a turbo charged diesel engine. In the programming world, building the 240 is quite simple. You just extend the 140 with a new engine.


When you extend the model 140, you acquire all the properties and methods of the 140. The color of the car, the shape, its ability to stop, start and steer are all now properties of the 240. But there's now a problem. You don't want the same engine. This is where polymorphism comes in. This is the ability to override a method or property belonging to the master class (or parent--in this case the 140).

Unit Testing

One of the fundamental challenges of programming is knowing that your program will do exactly what it should do, nothing more, nothing less. This problem is alleviated by the concept of unit testing. Unit testing is made easier in an object-oriented paradigm because you can test each black-box class as a unit.

Some popular unit testing frameworks are these:

No comments yet.
You must be logged in to post a comment.