Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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.


Replies are listed 'Best First'.
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.

      ...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.

        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?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2022-10-02 07:37 GMT
Find Nodes?
    Voting Booth?
    My preferred way to holiday/vacation is:

    Results (8 votes). Check out past polls.