The 'arrow notation' is just dereferencing. Some variable is a reference (something like a pointer, if you're a C person) to another variable. We can pass that reference around like we pass any scalar around. So, instead of passing a huge hash to a function, we might pass a reference to that hash into the function instead, saving memory usage.

Just putting a package in a module and use-ing it also isn't OO programming. That's modular programming, which is an excellent thing to do in any form of programming. By modularizing, you're factoring out often-used pieces of code, making it easier to manage, debug, maintain, upgrade, and re-use. Yes, reusability is a "hallmark" of OO programming, but it's not restricted to being something only OO can do.

What is OO programming has less to do with how you write your code as how you think about your code. Some programmers were instinctively writing OO-like code back in the 50's, well before any OO languages were invented. (If you think about it, why would OO languages have been invented, save to facilitate what some programmers were already trying to do?)

So, instead of OO programming, we should be talking about OO design. The big thing, for me, about OO design is thinking about your program as a series of act-ers, or agents. Each one knows about certain information and how to do certain things. They also have a number of ways they know how to talk, or interface. The only way anyone can get them to do anything (including giving knowledge of their information) is by using this interface.

How is tie-ing related to OO? Well, you have some class, or specification of what the object can and cannot do. That is Tie::Scalar, in your example. You have an interface, which would be creating it and asking for its value. (Actually, the interface to Tie::* is any action you can do on that type of variable, which only strengthens my argument that Perl variables are objects.) You have a way of defining that interface, and you can create many "objects" of that type, or class.

From a layman's point of view, that sounds relatively close to OO to me. (Yes, I'm avoiding the technical definitions, because they don't seem necessary right now.)

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.


In reply to What is OO? (was Re3: Tying) by dragonchild
in thread Need simple example tying scalar to localtime() by blueflashlight

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.