
When I was in graduate school, I interned at Hewlett Packard. There was an engineer there who used verilog, and he was always writing scripts and using macros and bindkeys to save typing. His reasoning was that his fingers and hands were only going to type so many characters before old age, arthritis or some RSI set it. Having read Programming Perl, I assumed a second motive, this was a corollary to Laziness.
At the WebGUI User's Conference in 2008, I talked about how WebGUI's version control system would alter the contents of an object in the database without updating any currently instanciated objects. This can lead to stale copies in memory of the object. One easy way to get a copy is to do:
my $asset = WebGUI::Asset->newByDynamicClass($asset->session, $asset->getId);
After typing that several times, it became obvious to Graham and I that it would make sense to encapsulate that in a method of its own. Now, in WebGUI 7.7 and 7.8, you can do this:
my $asset = $asset->cloneFromDb;
That saves you 35 character of typing, and makes it very clear what you're doing. Not only that, but in the future, should we need to do additional work, we only need to change it in 1 place.
Nice piece of API!

Copyright 2010 perlDreamer Consulting | All Rights Reserved | Site Map | Graphic Design by Plain Black