Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
On the contrary, to me, Acme::Playmate is a very good example of a simple object, and it encapsulates at least those three attributes you had in your sample code. Most importantly, the class does abstract an entity the author perceives.

I'm with Ovid on this one. The example under discussion is just a plain old data structure dressed up in a little OO clothing. If you remove the bless line from the constructor, you get back a plain ordinary hash reference that has *all* of the functionality of the so-called object. It is useless OO, as is the following:

#!/usr/bin/perl -w use strict; sub whatever { bless {name => 'pg', forum => 'perlmonks'}, 'NonObject'; } my $obj = whatever(); print $obj->{name},"\n"; print $obj->{forum},"\n";
1.Everything in the real world is an object (class is the collective abstraction of object).

Everything in the real world is *not* an object, and, conversely, a good many of the objects we create in our programs are 'objectifications' of process (not that that is a bad thing).

In reply to Re: Re: Often Overlooked OO Programming Guidelines by Anonymous Monk
in thread Often Overlooked OO Programming Guidelines by Ovid

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (2)
    As of 2020-09-20 16:37 GMT
    Find Nodes?
      Voting Booth?
      If at first I donít succeed, I Ö

      Results (121 votes). Check out past polls.