develooper Front page | perl.perl5.porters | Postings from March 2011

Re: Revising Perl's OO docs - a new OO tutorial

Thread Previous | Thread Next
From:
Steffen Mueller
Date:
March 8, 2011 11:02
Subject:
Re: Revising Perl's OO docs - a new OO tutorial
Message ID:
4D767D4A.3090502@cpan.org
On 03/07/2011 10:45 PM, Jan Dubois wrote:
> You could also just use hash syntax for your attribute accessors,
> and implement your object using a tied hash.  People seem to assume
> that exposing attributes as hash elements somehow "leak" your
> implementation, but that simply isn't true.  E.g. Win32::OLE
> uses this mechanism to expose property accessors to the underlying
> COM objects:

[...]

> You actually need 2 hashes per object for this though, one for the
> externally visible tied interface, and one to store the internal
> object data.

I just encountered such an interface at work in conjunction with 
inside-out objects to expose the IOOs as hashref-alikes.

This must be the single most horrible API in Perl ever. It abuses tie. 
It pretends to be a hash when it is not for no good reason. It can 
return lists from $obj->{foo}. But worst of all: It requires programmers 
to think hard about whether they're violating encapsulation or not! 
Please. Make it stop.

--Steffen

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About