Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: High level OOP query

by hippo (Abbot)
on Oct 24, 2013 at 12:57 UTC ( #1059449=note: print w/replies, xml ) Need Help??

in reply to High level OOP query

I couldn't comment on the norm, but I think both are acceptable and which you use will be determined by what sort of object you are creating and how it will be used.

Personally, I tend to use new to create an empty object and then optionally call init from within new to populate it based on arguments to new. The advantage in doing it this way is that you can create an empty object efficiently or create a populated object with a single call from the calling routine, or create an empty object now and then populate it later by calling init directly from the calling routine. I don't see many downsides to this approach, certainly in the general case.

But yes, don't get bogged down by this. There are much bigger fish to fry in the wonderful world of OOP. And before you go too much further down the roll-your-own path have you looked at the Modern Perl book or directly at Moose/Mouse/Moo?

Updated to explain the call tree more clearly.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1059449]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2018-05-27 21:51 GMT
Find Nodes?
    Voting Booth?