Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
1) Are there instances where OO perl is the only choice?

No -- just as there are no instances where perl itself is the only choice. But there are cases where programmers are much better off using OO perl, as evidenced by the many OO-style CPAN modules that have become essential tools in many a perl coder's daily activities. While a number of posts here (including some of mine) have defended the legitimacy of procedural coding and carped against "OO or die!" fetishists, there's no denying that OO should be the preferred approach for many tasks.

2) Say you've written a pretty large program written mostly in proceduaral perl. Can you easily re-write that program in OO perl later if you choose to?

Maybe a more pertinent question might be "can you write an app using just procedural syntax and structure, but do it in such a way that it could look like (and could be transformed pretty easily into) a `real' OO design?" Well, yes, sort of; to start with, use strict, and don't use any global variables; as you find that you need some set of subroutines that all manipulate the same data in various ways, group those subs together in one file (or inside a set of curly braces), and put the data in there with them. This is the start of building an object -- all it needs is a package statement at the top (to declare a name space), and a sub called "new" that includes a "bless" statement, and presto, it's an object. (Well, there might be a little more to it than that, but not much.)

update: I keep forgetting about inheritance! This is something that really does come in very handy in a number of cases, and I can't imagine any way of doing it properly with just procedural tools. As I see it, this is the one thing that really sets OO design apart -- and to very good effect, because the only alternatives in a non-OO approach are not at all attractive.

3) Does anybody have any idea how perl 6's implementation of OO perl is going to be like? If so, is it going to be differnt from the current implementation?

So, you haven't internalized perl5's OO syntax yet (well, neither have I, really -- I still have to look up examples and man pages and Damian's beautiful OO book on those occasions when I want to make an OO module). And you're wondering if this stuff will be easier in perl6, so that maybe you should wait and not waste your time learning a soon-to-be-obsolete syntax...

Don't wait. Learn it now, with the syntax as it is. When perl6 comes out (I haven't heard anyone holding their breath...), it's design will be intended, in part, to implement all the functionality and concepts available in perl5, and then some; it will also be intended to provide a smooth and relatively painless transition out of perl5 syntax. So getting to know the OO landscape, even with the not-so-sporty vehicle of perl5, will be time well spent.

In reply to Re: perl OO - to use or not to use by graff
in thread perl OO - to use or not to use by kiat

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    [LanX]: Jeez ... the new location for GPW so remote that hotels are cheaper than AirBnB oO
    [LanX]: ... and I can get faster to the Dutch PW or French PW ...
    LanX ...(by train from Frankfurt)
    [LanX]: renting a car could be an option ...
    [NodeReaper]: speedboat

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (8)
    As of 2018-03-19 11:53 GMT
    Find Nodes?
      Voting Booth?
      When I think of a mole I think of:

      Results (239 votes). Check out past polls.