Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: Good practice for OO module defaults

by 1nickt (Abbot)
on Apr 10, 2019 at 10:53 UTC ( #1232399=note: print w/replies, xml ) Need Help??


in reply to Re^2: Good practice for OO module defaults
in thread Good practice for OO module defaults

"... unless there's a good reason for them not to be."

As for the recommendation, I can't find the original source but am sure I have read it in some doc somewhere. In my own experience it's usually the case that many if not most attributes depend on others or other things, and rather than try to remember all that I am lazy and use lazy and a builder. Of course that is not so in all cases, including e.g. your example of an attribute that has a static value.


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^4: Good practice for OO module defaults
by tobyink (Canon) on Apr 10, 2019 at 14:02 UTC

    Sure, if an attribute's default value is going to be based on other attributes, then make it a lazy default. For most people, that's a minority of attributes though.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2020-07-12 09:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?