Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.perl.misc > #4730

Re: getting hash reference from a package

From tmcd@panix.com (Tim McDaniel)
Newsgroups comp.lang.perl.misc
Subject Re: getting hash reference from a package
Date 2012-03-14 15:37 +0000
Organization Tim McDaniel's at Panix
Message-ID <jjqdvs$4op$1@reader1.panix.com> (permalink)
References <jjnsjo$57f$1@dont-email.me> <jjo2d1$8cj$1@dont-email.me> <NaY7r.589637$lb1.44216@news.usenetserver.com> <ina639-3qd.ln1@news.rtij.nl>

Show all headers | View raw


In article <ina639-3qd.ln1@news.rtij.nl>,
Martijn Lievaart  <m@rtij.nl.invlalid> wrote:
>On Wed, 14 Mar 2012 01:57:07 -0600, Jack wrote:
>
>> Question: Is it proper to access a package variable directly? Would
>> it not be better to provide a method to retrieve the reference?
>
>Even better, provide a getter and a setter (or combine them).

That's certainly the fashion in object-oriented code.  I may be
showing my ignorance, but I'm afraid I don't see the benefit in doing
that for a single uncomplicated global variable.  An object with
complicated semantics, or semantics that must be constrained and
checked for validity, of course -- that's one of the points of
object-oriented code, and it's a very useful technique.  But a simple
count, say, or a string that's unrelated to anything else?  Why not
require getters and setters for that are visible for more than 50
lines, say, or for all variables?

-- 
Tim McDaniel, tmcd@panix.com

Back to comp.lang.perl.misc | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

getting hash reference from a package Bill M <wpmccormick@just_about_everywhere.com> - 2012-03-13 11:28 -0500
  Re: getting hash reference from a package Bill M <wpmccormick@just_about_everywhere.com> - 2012-03-13 11:44 -0500
    Re: getting hash reference from a package tmcd@panix.com (Tim McDaniel) - 2012-03-13 17:56 +0000
      Re: getting hash reference from a package Bill M <wpmccormick@just_about_everywhere.com> - 2012-03-13 13:07 -0500
        Re: getting hash reference from a package Jack <goodcall1@hotmail.com> - 2012-03-14 01:57 -0600
          Re: getting hash reference from a package Martijn Lievaart <m@rtij.nl.invlalid> - 2012-03-14 12:06 +0100
            Re: getting hash reference from a package tmcd@panix.com (Tim McDaniel) - 2012-03-14 15:37 +0000
              Re: getting hash reference from a package Ben Morrow <ben@morrow.me.uk> - 2012-03-14 17:54 +0000
          Re: getting hash reference from a package Ben Morrow <ben@morrow.me.uk> - 2012-03-14 14:27 +0000
            Re: getting hash reference from a package Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-03-14 18:28 +0000
              Re: getting hash reference from a package Ben Morrow <ben@morrow.me.uk> - 2012-03-14 21:08 +0000
                Re: getting hash reference from a package Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-03-14 21:23 +0000
          Re: getting hash reference from a package gbacon@hiwaay.net (Greg Bacon) - 2012-03-14 12:20 -0500
            Re: getting hash reference from a package Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-03-14 18:14 +0000
              Re: getting hash reference from a package gbacon@hiwaay.net (Greg Bacon) - 2012-03-16 12:11 -0500
                Re: getting hash reference from a package Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-03-18 22:12 +0000
                Re: getting hash reference from a package gbacon@hiwaay.net (Greg Bacon) - 2012-03-20 10:28 -0500
          Re: getting hash reference from a package Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-03-14 20:52 +0000

csiph-web