NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
But but... (Score:1)
Re: (Score:1)
Most of the noise was taking the idea and working out which implementations don't suck.
Re: (Score:1)
The implementation that doesn’t suck is called Hash::Util::FieldHash, courtesy of 5.10, coming to a CPAN near you soon.
Geroff my privates! (Score:1)
cultural solutions (Score:1)
There are definite benefits, like improved encapsulation, but I don't need a shotgun -- especially one that has lots of overhead costs. In Perl, avoiding tight coupling can be reduced to a cultural problem, in my experience.
Sometimes, I use a pattern like this:
$object->{__PACKAGE__}{attr} = $value;
Now the object's guts are well divided into areas of authority. If you, Subclass::Happy start screwing aro
rjbs
Re: (Score:1)
I suppose Ruby-community-style monkeypatching is OK with you too?
Re: (Score:1)
How is that an endorsement of anything even remotely like monkeypatching?
rjbs
Re: (Score:2)
Re: (Score:1)
In other words: change the behavior of shared code by messing about with its guts, rather than by producing a subclass that you use. It's fast and easy (so a monkey can do it), acts like you've patched the source, and affects all the other code you've loaded and probably not reviewed for how
rjbs
Re: (Score:2)
Re: (Score:1)
I agree it can be useful in limited and highly constrained circumstances. It has its place, much like GOTO, which I am fond of defending against dogmatists despite the fact that I practically never use it.
The most common form among Ruby folk is adding methods to classes you don’t own. That does indeed seem to be SOP. Eg. Rake (the build system written in Ruby) stuffs a kitchen sink of filesystem-related methods into
Object. Changing existing behaviour is less common, but they do that too; cf. the ChRe: (Score:1)
Oops.
rjbs
Re: (Score:1)
You made an unqualified claim that inside-out objects have some unspecified overhead cost and then said the absence of their benefits is only a problem if you make it one. That’s the same sort of argument by which monkeypatching gets justified – “it’s only a problem in practice if you make it one, and doing it this way is easier.” I cringe in embarrassment whenever Perl hackers trot out the living-room-and-shotgun line in the presence of others (and when it’s just Perl fo
Re: (Score:1)
You made an unqualified claim that inside-out objects have some unspecified overhead cost and then said the absence of their benefits is only a problem if you make it one. That’s the same sort of argument by which monkeypatching gets justified – “it’s only a problem in practice if you make it one, and doing it this way is easier.” I cringe in embarrassment whenever Perl hackers trot out the living-room-and-shotgun line in the presence of others (and when it’s just Perl folk I roll my eyes).
I must not have been clear enough. I will be very plainspoken and see if that helps me communicate any better: It is always a bad practice to alter an objects behavior without limiting the scope of those modifications. It is also always a bad practice to alter the data associated with an object without controlling the way that the object 's methods and its data interact. Unfortunately, it is difficult to do this in Perl. One solution is inside-out objects, which prevent the user from altering an objec
rjbs
Re: (Score:2)
Not once in the decade I've been writing Perl have I needed O::IO or it's ilk.
@JAPH = qw(Hacker Perl Another Just);
print reverse @JAPH;
Re: (Score:1)
The other is turning (possibly hard to find) runtime errors into compile time errors.
Preferring $hash -> {attr} (or $hash -> {__PACKAGE__} {attr}) over $attr {refaddr $ref} is, IMO, as sane as preferring package variable and 'no strict' over lexical variables and 'use strict'.
Inside-Out Objects has never been about providing encapsulation with a shotgun. It simply favours perl5-style variables ('strict', 'lexical') over per
Re: (Score:1)
rjbs
OIO Assistance (Score:1)
While OIO's POD does discuss some of the advantages of using the inside-out object model, it also lists several more involved discussions on the matter including Damian Conway's book Perl Best Practices.
OIO does provide methods for maintaining persistent data, bu
Re: (Score:2)
The number of places where it was needlessly complex and required copy and pasting where any sensible Class framework allows you to just specify the columns and have it DTRT.
"OIO does provide methods for maintaining persistent data, but not directly to a database. However,
@JAPH = qw(Hacker Perl Another Just);
print reverse @JAPH;
Re: (Score:1)
Errm, DBIx::Class is an object-relational mapper, not a class framework. Criticising Object::InsideOut for not being an ORM is like criticizing perl for not being an editor. What are you even talking about?
Re: (Score:2)
@JAPH = qw(Hacker Perl Another Just);
print reverse @JAPH;
Re: (Score:1)
No, CDBI and DBIC are not the same kind of thing as Class::Accessor. You don’t write programs with CDBI/DBIC if they have nothing to do with a database, and you don’t stick non-database-related logic in your CDBI/DBIC classes either.
The Right Tool for the Job (Score:1)
It's not a requirement - it's optional. Cut out the regexes, and your preformance will go up (probably significantly). The regex option is there to provide greater programming flexibility if that is desired. As with any feature, if it's not needed, then don't use it.
"There is a great deal more to useful object persistence than a couple of SQL statements..."
The requirement to tie your objects to a database was evidently something the or
Re: (Score:2)
Class::Accessor and it's like allow me to specify my attributes in a single line, even Moose is less bizarre in how you specify attributes.
I'm surprised people would choose to use O::IO in production code, I certainl
@JAPH = qw(Hacker Perl Another Just);
print reverse @JAPH;