Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: Often Overlooked OO Programming Guidelines

by Anonymous Monk
on Dec 30, 2003 at 05:40 UTC ( [id://317628]=note: print w/replies, xml ) Need Help??


in reply to Re: Often Overlooked OO Programming Guidelines
in thread Often Overlooked OO Programming Guidelines

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2024-04-25 19:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found