Matthew Byng-Maddick wrote:
> 
> On Tue, 5 Dec 2000, kyle dawkins wrote:
> > * We implement a "mode" under mod_perl, kind of like "use strict", that
> > suddenly forces Perl to behave well from an object-oriented standpoint.  By
> > this, I mean taking some of the power away from Perl that causes trouble,
> > like allowing anyone to write instance data on an arbitrary instance of a
> > class...

People are looking at this sort of thing. Damian Conway wrote
Tie::SecureHash and Class::Contract, which may be driving at this sort
of thing.

The latter implements "design by contract", as seen in Eiffel. I read
Damien's paper on it, but haven't used it - there are four things that
put me off:
1. The difficulty of modifying existing classes to work with it
2. The magic of "flyweight scalars", which I haven't yet got my head
around
3. "This code is funky"-type disclaimers scare me.
4. It looks like he just defines "data types" as LIST, ARRAY, the usual
Perl primitives.
   This is of limited use, IMHO; being able to _define_ rules for data
types (eg. valid URI;
   reference to FooID in table Foo in database bar) would be more
powerful.
   (Not that these should all be checked every time, unless you're
implementing a Snail,
   but C::C does have the ability to switch checks off, eg, in a live
environment. Though live users
   make very thorough testers :-/)

I can see why people want encapsulation, though I've rarely seen
problems due to people violating it. This may be pure luck. *Lack* of
encapsulation may provide clues when you hit something with Data::Dumper
& find out what's going on on the inside.

IMHO, assertions, data type definitions, pre & post conditions are v.
useful things. Define interfaces to methods & functions. This isn't
necessarily the right approach - especially at the beginning of a
project - but it is in some cases, and AFAIK there is little to automate
this stuff available in Perl. Putting up these walls can *really* help
isolate problems.

Eiffel & Class::Contract allow conditions to be *inherited*. So these
approaches work hand-in-hand with OO *and/or* re-use.

Cheers

--
Tim Sweetman
A L Digital
'Now you see this one-eyed midget shouting the word "now"...'
 --- Bob Dylan

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to