[Chicago-talk] Proper encapsulation

Jay Strauss me at heyjay.com
Fri Jan 21 22:01:56 PST 2005

Hi, I'm using Class::Accessor, it provides a method ->mk_accessors 
(which ironically creates setters and getters for your class).  Anyway, 
I think typically you'd invoke this from the class, but you can do it 
from the code that instatiates the class.



use 5.006;
use strict;
use warnings;

package SomeClass;

use base qw/Class::Accessor/;

package main;


my $o = SomeClass->new;

print $o->cache,"\n";

My question is: does creating the accessors from outside the class 
violate OO principles, or is acceptable since the functionality is provided?


More information about the Chicago-talk mailing list