As I see things, the biggest advantage of using inside-out object is typo checking. $self->{attribute} becomes $attribute{$self}, which allows typos of attribute to be caught at compile time, rather than having them lead to weird problems at run-time. You mitigated this by providing accessors, but not by using closures.
Inside-out objects also provide data protection. If the attribute hash is a my variable, neither the main program nor other modules can access the attributes without using the accessors. Howver, in your closure code, anyone can do &{ $obj }("BALANCE", '1000000');. True, sanity checks could be added inside the closure, but inside-out objects could ban access to BALANCE completely.
In reply to Re: OO - inside-out or by means of a anonymous sub?
by ikegami
in thread OO - inside-out or by means of a anonymous sub?
by gargle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |