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.


DWIM is Perl's answer to Gödel

In reply to Re: Procedural and Object Oriented Perl Code by GrandFather
in thread Procedural and Object Oriented Perl Code by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.