Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Object Oriented Orientation

by dwm042 (Priest)
on Aug 01, 2011 at 19:28 UTC ( #917903=note: print w/ replies, xml ) Need Help??


in reply to Object Oriented Orientation

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.


Comment on Re: Object Oriented Orientation
Re^2: Object Oriented Orientation
by sundialsvc4 (Abbot) on Aug 02, 2011 at 11:21 UTC

    ++

    There speakes the voice of Wisdom.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://917903]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (10)
As of 2014-09-22 19:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (198 votes), past polls