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.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.