> Personally, I think the only difference is object oriented
> programming and the library.
JR> few nice things that 'tidy-up' the C language but I fail to see the
advanta
JR> of this object orientated approach (OOA). At first I thought the class
JR> I will learn to appreciate the subtleties of C++ and the OOA with time
but
JR> think the improvements offered by C++ do not justify the overheads it
incur
It took me 15 years to learn to appreciate OO programming. At first,
OOP doesn't seem to be a big deal - after learning to use it, I
really appreciate what OOP has to offer.
#1 - data encapsilation:
With a data structure and function that uses it can mess things up.
With a few 1000 lines of code, it becomes very difficult to find
where things went wrong. If only an object alters its own data, you
know only it should be allowed to mess things up.
Data encapsilation reduces the number of functions responsible for
causing problems. (Yes, you can do the same thing with libraries.)
#2 - Debugging
You can create one object at a time and fully test each member
function with a simple drive program. Normally, one would have to
run a program and test what happens once a certain portion of the
code has been reached.
Once you piece all the objects together, you can be relatively
sure that the objects function as they should.
(Yes, you can do the same thing with libraries.)
#3 - Polymorphism and code reduction
Let's pretend that you have 5 types of bank accounts.
(checking, savings, joint, etc)
How many Transfer() functions would you have to write to allow
each account to transfer to another account? (5 * 5 = 25)
With polymophism, you can write one function that does the
work of 25.
#4 - Software engineering paridigms
RAD development is easily implimented using objects.
(as well as other models of development)
#5 - Easy updates
Lets say you have a data structure and there's a new rule to
make when you add an item to the data structure. How many places
will you have to alter traditional code in order to enforce the
new rule? If you have and add() function for that object, you
only need to update it in one place.
In closing: You can do most of the same things with a library -
except polymorphism - put OOP forces you to do things the
right way. You can effectively reduce code, design time,
debug time using a pre-defined object model.
--- GEcho 1.00
---------------
* Origin: Digital OnLine Magazine! - (409)838-8237 (1:3811/350)
|