Just another Perl shrine | |
PerlMonks |
Re: [RFC] Review of module code and PODby GrandFather (Saint) |
on Apr 01, 2021 at 00:05 UTC ( [id://11130651]=note: print w/replies, xml ) | Need Help?? |
As a general thing lines that are very long, especially if there is important stuff at the end, and even worse of the structure is convoluted, compared with short lines are hard to understand. Keep your lines short, or at least wrap them sensibly. For example:
is easier to maintain written:
Consider using spaces instead of tabs for indentation. Consider having new return an instance of Bod::CRM with its error field set, or throw an exception, for a DB connection failure. Consider removing warnings in lower level code. Low level code may not have enough context to be really helpful and low level warnings can end up generating a noisy log. Calling code can emit warnings if appropriate and can generally provide a better semantic context. Consider using exceptions for handling all errors so that calling code can chunk error handling into blocks of related code rather than having to deal with handling errors on all function calls. That extends quite well to having DBI code throw exceptions rather than having fine grain error checking at a low level (see RaiseWarn and RaiseError in DBI). Consider passing named parameters to find and add. That way your existing hash ref gets passed in as a hash with no other change, but a simple find doesn't need to have a hash ref spun up. That makes it easier to write the code and easier to read and check:
Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
In Section
Meditations
|
|