Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^4: regex transforms of object attributes

by Aragorn (Curate)
on Jun 19, 2004 at 09:09 UTC ( #368137=note: print w/ replies, xml ) Need Help??


in reply to Re^3: regex transforms of object attributes
in thread regex transforms of object attributes

Who says that the $self->content variable stays a variable in the future? Dealing with the attribute doesn't cuase the attribute to become uncapsulated, but it does violate information hiding. An object has a published interface (the methods) which are more or less guaranteed to work. The upside is that when the author of the module/class feels there is a better way to implement things, she can do that without changes to the external interface.

Of course you can use the attribute directly. No one is stopping you. It'll probably work just fine. Just don't get upset when it suddenly breaks your programs when you install a new version.

Arjen


Comment on Re^4: regex transforms of object attributes
Download Code
Re^5: regex transforms of object attributes
by Roy Johnson (Monsignor) on Jun 19, 2004 at 11:24 UTC
    But honestly: if it's settable and gettable, what are the chances that it's not going to be a simple variable?

    And a minute after posting that, I encountered this node, that answered my question one way: it's possible that a value needs to be encoded to be stored, and decoded to be retrieved. So there I have it. On the other hand, if you use a tied variable, you can do your encoding and decoding transparently and not break encapsulation...


    We're not really tightening our belts, it just feels that way because we're getting fatter.
      Howdy!

      ...when it gets reimplemented as a value stored in a database somewhere, or stored remotely, such that you access it via SOAP or HTTP or carrier pigeon...or as a value in a hash or array somewhere. But you don't have a need to know...

      A procedural interface, whether a get and set pair, or a polymorphic accesser/mutator, provides a way to obtain and change the value while keeping your actions decoupled from the specific storage mechanism.

      yours,
      Michael
        It doesn't matter how it's stored. If the interface is set-a-scalar, get-a-scalar, you can do it with a tied scalar. See my meditation on the subject.

        We're not really tightening our belts, it just feels that way because we're getting fatter.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2014-08-30 13:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (293 votes), past polls