Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Comments, suggestions? Do ya'll use OO Perl a lot?

I probably use OO Perl far less than many of the far better programmers who have replied, and my opinion is that of a sys admin who generally is asked to write fast and dirty scripts to Just Get Things Done.

For small programs, under 100-200 lines or so, I see no advantage to writing in OO. Using OO? Plenty of advantage, because how else do I get my programs to be under 100 lines? Perl's brevity is in part due to the extensive CPAN library programmers can use.

The moment you start thinking about code you would like to stick around, code you would like to keep and reuse, code you would like to share, the advantages of OO come to the fore. IMO, it takes more work to write OO, but the final product has a better defined interface, is better isolated (that word encapsulation raises its head), is easier to hand over to a beginner and have it "just work".

It's better, in the long run, to have a 2,000 line object in a module that gets turned into a 30 line main program than 1,500-1,800 lines of functional chicken scratch. People might "get" the point reading the 30 line main program. People (including you) will forget the details in your 1,000 line+ bit of chicken scratch. You'll also forget that 2,000 line module too, but you have a better chance of going, "Hey, I sort of remember what I did here.."

When I first started into Perl OO, I wrote an object that encapsulated a closure that gave me a date iterator. It was just practice, until 2 months later it became a crucial part of a production program. So even dabbling in OO will give you a bit of a toolkit you can put to practical use later.

David.

In reply to Re: Object Oriented Orientation by dwm042
in thread Object Oriented Orientation by koolgirl

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2024-03-28 10:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found