Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^9: The future of Perl?

by Arunbear (Prior)
on Dec 16, 2014 at 18:25 UTC ( [id://1110534]=note: print w/replies, xml ) Need Help??


in reply to Re^8: The future of Perl?
in thread The future of Perl?

By exposing the 'items' attribute via a method, you are telling users of the class that they can use it like this:
6:06% reply -I . 0> use fQ_moonimal; 1> my $q = fQ_moonimal->new(size => 3); $res[0] = bless( { 'items' => [], 'size' => 3 }, 'fQ_moonimal' ) 2> $q->push(2); $res[1] = '' 3> $q->push(3); $res[2] = '' 4> $q->push(5); $res[3] = '' 5> $q $res[4] = bless( { 'items' => [ 2, 3, 5 ], 'size' => 3 }, 'fQ_moonimal' ) 6> push @{ $q->items }, 7, 11, 13; $res[5] = 6 7> $q $res[6] = bless( { 'items' => [ 2, 3, 5, 7, 11, 13 ], 'size' => 3 }, 'fQ_moonimal' ) 8>
So this version of the queue is not really fixed size. Encapsulation is one of the main motivations for doing OOP in the first place, and giving it up to get feature $X doesn't amount to superior OOP.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2024-04-18 12:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found