my $class;
my $sql;
my @bindparms;
my $Rowcount;
my $Status;
my $cntl;
my $db;
my $start;
my $end;
my $posn;
my $SQLStr;
my $host;
my $Properties;
@bindparms = $_;
$class = shift @bindparms;
$cntl = shift @bindparms;
$sql = shift @bindparms;
A couple of stylistic points, from the above sub-set of your code.
- It's neater to declare variables in a list, so as to make better use of space. So,
my ( $class, $sql, .. );
is much cleaner than what you have, which is one variable declaration per line. I would probably group related variables together -- they don't all have to be on a single line.
- You don't have to group variable declarations all at the beginning of a block, as we used to do in C. (I believe that was because they needed to be allocated on the stack by the compiler.) Declare variables when you're about to use them.
- I won't comment on the choice of camelCase versus snake_case, but it is a good idea to be consistent. You've got some variable names that are lower case, and some that are Capital case (initial capital letter, followed by lower case).
- You set @bindparams to @_, then use shift to initialize the three variables $class, $cntl and $sql. It's probably easier and cleaner just to say
my ( $class, $cntl, $sql ) = @_;
- Whenever you're passing arguments into a method, you should do validation on the arguments. At the very least, check each input to find out a) Is it defined? and b) Does it have a reasonable value? Only move forward if the input arguments are absolutely fine; otherwise, output a useful error message and return (or die/croak, whichever is appropriate).
Alex / talexb / Toronto
Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|