Previous section To contents Next section

6.3 How does this help?

Ok, why is it a good idea to use object oriented programming? Well if you believe what you hear, the biggest advantage is that you can re-use your code in several projects. In my experience this is not the case.

In my experience, the advantages of object oriented programming are:

Modular programming made easy
Using The approach makes it easy to divide a project into smaller pieces, these pieces are usually easier to write than the whole.
Local data scope
This is a very nifty thing with object oriented programs. If your program uses several files, windows, stacks, TCP connections or whatever, you simply write a program that handles one such file, window, stack or TCP connection. If correctly written, you can then just create many clones of that program.
Using the same interface to different objects
I can write a function that take a stream as an argument and writes data to this stream. Later I might wish to write this data to a window instead. I can then create an object that has the same methods as a stream (specifically the write method) and send that to the function that outputs the data.
Most of these things can be done without object orientation, but it is object orientation that makes them easy.

Previous section To contents Next section