Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re^3: Strict isn't strict enough (stop it)

by tye (Sage)
on Dec 31, 2011 at 18:02 UTC ( #945758=note: print w/replies, xml ) Need Help??

in reply to Re^2: Strict isn't strict enough (stop it)
in thread Strict isn't strict enough

"Don't poke yourself in the eye."
"Doctor, it hurts when I slice through my eye with a chainsaw."

Although the docs you linked to are a bit over-the-top (quite an unfortunate thing in such a core module), they make a good point:

To provide the capability to set/get class-wide settings, it is best instead to provide accessors as subroutines or class methods instead.

The docs said, "Don't do X, do Y instead" and you used them to justify, "Since I can't do X, I'll do W" where "W" is a much worse idea than "X".

What you are doing is equivalent to having public attributes in a class. That makes for pretty bad class design (of course, some people have a hard time even conceiving of class design without the equivalent of public attributes; for example, take a critical look at Moose ;).

I'll let you struggle with whether you should abandon exposing global variables for your interface and replace them with global subroutines instead. There can certainly be advantages to that. But I won't try to scare you into such a decision with over-the-top proclamations. "Trust me". (:

- tye        

  • Comment on Re^3: Strict isn't strict enough (stop it)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://945758]
[1nickt]: \my %foo = { bar => 1 }; say $foo{bar};
[Corion]: 1nickt: Would be great, especially for naming parameters in @_.
[Corion]: When you pass an arrayref, you get to treat it like a local array. But then, I'm cautious with the experimental features, because just when I thought function signatures were a set thing, there is a proposal to use sub [ $foo, $bar ] { ... } to ...
[Corion]: ... declare the parameters, instead of the more common sub ($foo, $bar) { ... }

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2017-11-17 20:40 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (272 votes). Check out past polls.