It allows you to manipulate objects as atomic entities.
For instance, you can instantiate an 'object' that represents maybe an object in 3d. This object can contain all of the data required to draw the object within itself, along with the functions that are used to manipulate it.
I can call my3dobject.Rotate(90) without knowing anything about the internal data structures that actually make up the object.
If there were a function that was designed for drawing objects to the screen, I could pass my object to that function to draw it to the screen, again without knowing anything about the internal workings of it.
Also, someone could go back in later and change the internal workings of the object completely without me having to rewrite any of my code that uses the object.
Compared to non-OOP, to do the same things, I would have to have knowledge of the data structures being used to do the certain functions, and I would have to do all of the housekeeping on the data myself. I would also have to pass the data explicitly to every function that used it. If the way in which the data was stored changed, I would have to rewrite my whole program.
__________________ Desktop machine: 2 x Opteron 246, Asus K8N-DL, 2GB PC3200 ECC Reg., XFX GeForce 6600GT, 74gb WD Raptor, 2 x 19\" LCDs, Windows XP x64
Server machine: Intel P4 3.0GHz 2MB EM64T, ECS i865pe, 1GB PC3200, 36gb WD Raptor, Windows Server 2003
Laptop: Dell Inspiron 9100 (Intel P4 3.2GHz 1MB Prescott, i865pe, 512MB PC3200, Mobility Radeon 9700, DVD+R/DL Burner), Windows XP
Linux: P3 450Mhz, 386MB ram, Slackware 10.1 (Running mySQL/Apache) |