in reply to Procedural and Object Oriented Perl Code
Procedural code uses stuff like loops and subroutines to manipulate data that is stored in either global data structures or is passed around as parameters.
Object oriented code ties the data up into a bundle called an "object" and associates "methods" with the object. The idea is that you can create objects where the details of how the data can be manipulated is embodied in the object rather than being a bunch separate subroutines and data that get munged together in some fairly haphazard fashion.
The big gain with object oriented programming comes when define the objects in terms of classes and allow the same data manipulation to be applied to different but related data.
An example might be a class that wraps up some database functionality for dealing with tables. So you might have a Table class that allows you to provide the name and structure of the table (the data) and allows you to do things like create the table (given a database handle - most often an object actually) and then do stuff with it like insert new records into the table, fetch records, update records and soon. The nice part is that once you have written the method to do each trick it really doesn't matter what the details of the table are, the methods work for all tables.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Procedural and Object Oriented Perl Code
by BrowserUk (Patriarch) on Mar 31, 2007 at 13:17 UTC | |
by RobPayne (Chaplain) on Mar 31, 2007 at 13:32 UTC |