[fpc-pascal]Why Oop?

Andreas K. Foerster Andreas at AKFoerster.de
Fri Feb 22 09:00:18 CET 2002

On Thu, Feb 21, 2002 at 10:30:24AM -0600, gj bart wrote:

>      I've yet to figure out why Object-Oriented programming is so
> important.  If I want to, say, write a program that simulates the game of
> blackjack, I just need the data, some shuffle routines, some decision
> tables, etc.  All this stuff about making objects and ancestors just seems
> superfluous.  If I am to use the routines later well, isn't that what a
> library is for?

Yes you are right. There is nothing about OOP, that you couldn't do
without it. It is just a different way of programming.

>      Obviously I'm missing something but I'm not clear what it is.  Aside
> from perhaps helping coordinate projects involving several individuals,
> what's the advantage?

That exactly is the main point: it helps structuring large projects.

For example you don't need so much parameters anymore, because
variables are bound to the object - so for your example any card can
have it's own x and y coordinate and you may just use the variable
names x and y in your procedure ("method") like global variables -
but they have different values for any card (instance of the object).

Another point is, that you can write more abstract procedures. For
example for moving anything, you can just say erase here and draw there,
while what is to be erased or drawn can be defined later and you can
use the same procedure for different things. That is why procedures are
called "methods" in OOP.
The same thing could be done with procedure-variables, but that would
become too confusing in large projects.


More information about the fpc-pascal mailing list