Originally Posted By: tacit
In a lot of ways, object oriented programming has been with the Mac from the start. The old-fashioned resources that were stored in a file's resource fork were objects; the idea was that you could modify those objects (which often represented things like user interface elements) without touching any of the code associated with them.


"I don't think that word means what you think it means" wink

at least in my arena, "object-oriented" refers to how data structures and the functions that operate on them are related.

object-oriented:


class COLOR
properties RED,BLUE,GREEN
function ColorIsSame(OTHERCOLOR)
if (my.RED=OTHERCOLOR.RED and my.BLUE=OTHERCOLOR.BLUE and my.GREEN=OTHERCOLOR.GREEN) then
return YES
otherwise
return NO

program:

if MYCRAYON.ColorIsSame(YOURCRAYON)
say "same!"
otherise
say "different"

notice how the program doesn't have to bother with the details of figuring out whether two colors are the same. it just asks the color to do the dirty work. This is helpful if you add another property, like ISGRAYSCALE. If you add that property, and are NOT using object-oriented programming, you'd have to hunt down every place in your program that you were working with a COLOR and possibly change it. COPY is another good instance. If you add a property, everywhere you COPY the object you'd need to modify code. With OO, you just do a NEWCRAYON = OLDCRAYON.MAKECOPY and let the COLOR do the work. Adding properties to COLOR won't break your code all over the place.



non-oo program:

NEWCRAYON.RED=OLDCRAYON.RED
NEWCRAYON.GREEN=OLDCRAYON.GREEN
NEWCRAYON.BLUE=OLDCRAYON.BLUE

... NEWCRAYON.GRAYSCALE = OLDCRAYON.GRAYSCALE <-- you have to add this line, possibly in many places scattered around


oo program:
NEWCRAYON=OLDCRAYON.COPY

that's it. you never have to touch that code. you make the above change in COLOR, once, only.

wait, we need to track if that color is in the gamut on the new laser printer. we need to add a property PRINTERXXSUPPORTS. Or maybe we need to add a whole array so we can track support for all five of our printers! Suddenly it becomes a huge headache to modify all the places we are copying or accessing colors, unless we are OO. It also greatly increases the chance you miss something somewhere and make a difficult-to-find bug.





I work for the Department of Redundancy Department