Paradigm of object oriented programming (OOP)



OOP presented in an abstract way:
Analyse the problem you want to solve with your program.
Scetch the solution in terms of interacting, but self-contained building blocks. They might incorporate data, methods to modify the data and even more basic building blocks. The building blocks form the elementary object in terms of which you try to formulate the solution of your problem.
These objects, as indicated above, might be vastly complicated and might be subject to another modularization.


OOP presented via an analogy:
As a child I used to play quite a lot with these fantastic colourful LEGO pieces. Some of my favourite "LEGO projects" were the construction of spaceships or naval battlecruisers (Well, this is how most of little boys are. At least I would hope so !). These colourful LEGO pieces of varying shape (wheels, windows, bricks etc.) are equipped with round bits and round holes fitting nicely into each other and establishing easy predefined connections between the different pieces.
The analogy of LEGO with OOP is as follows:
Instead of spaceships etc. I nowadays construct C++ code. Instead of LEGO pieces I use objects. These object have different shapes and different functions. Having programmed individual objects the task is to connect them in a predefined meaningful way inside a program.

Obviously it happens that you might need the same type of LEGO piece a couple of times for your solution. The same thing applies to C++ object inside a larger scale program. You might need the same type of object (like for instance a vector) a couple of times, so you would have to instantiate the same class a couple of times. In this sense the classes in C++ are templates for objects in terms of which you program your solution.

[top] [next]