in reply to Notes from the Refactoring Ward
There is a happy medium I often reach for instead:
my @todo = ( { label => 'foo', offset => 42, url => 'http://www.google.com' }, { label => 'bar', offset => 6, url => 'http://www.boingboing.net' }, . . . . . . { label => 'mumble', offset => 101, url => 'http://search.cpan.org' }, );
Sure, you may say that's introducing more duplication. But the benefit is a chunk of input that is a lot more self-documenting, without being as heavy as a whole new InputToFoo class (semantically speaking, of course -- we all know most objects in Perl are implemented as hashrefs anyway). Basically, I'm using named arguments instead of positional. Try it out sometime; you just might like it.
PS: you also might notice I used more descriptive keys than 'url', 'string' and 'number'. Obviously, I just invented them out of whole cloth, but if it's your application, you probably know what these chunks of data actually represent.
|
|---|