Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re^3: Are global variables "bad"?

by DStaal (Chaplain)
on Apr 21, 2009 at 17:32 UTC ( #759064=note: print w/replies, xml ) Need Help??

in reply to Re^2: Are global variables "bad"?
in thread Are global variables "bad"?

I don't actually see any particular reason to use a singleton in this case: You are parsing a file, and want to store it someplace. There is no particular reason (from what you've said) why parsing a different file, or even reparsing the file should be prevented. (Besides the fact of memory useage/speed, which to me isn't a reason for a singleton, just a reason to keep using the same object.)

Basically, it's extra complexity to prevent future uses. I don't see why either would be something you want.

Replies are listed 'Best First'.
Re^4: Are global variables "bad"?
by Porculus (Hermit) on Apr 21, 2009 at 19:38 UTC

    Agreed. The singleton is, when you get right down to it, really just a hack to add global variables to Java in an "object-oriented" way, dignified with a fancy name and notable mainly for being the design pattern people are by far the most likely to be able to remember off the tops of their heads.

    There are very few cases where singletons add value in a language like Perl. If your code is worth the effort of moving away from global variables, it's worth the effort of generalising completely (for example, allowing people to have multiple data sets open at once).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://759064]
[LanX]: I have my doubts, IMHO its a workaround if the glyph is missing
[LanX]: (they are pronounced differently)
[choroba]: perl -Mutf8 -Mfeature=fc -wE 'say fc "straße" eq fc "strasse"'
[choroba]: returns 1 for me
[choroba]: are they?
[LanX]: strict rules : the a is long in "straße" and short in "strasse"
[choroba]: So the "a" is different, not the "s" ;-)
[LanX]: people knowing that it's a workaround will pronounce it right
[LanX]: well
[LanX]: Maße and Masse are two very different words.

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (11)
As of 2018-03-21 15:47 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (268 votes). Check out past polls.