in reply to CGI DB interface
Take heed of sauoq's sage advice.
Just to expand slightly on matters more 'stylistic'. sauoq's point about perltidy referred to your formatting - indentation etc. It may sound petty ("what the h*ll does it matter how *pretty* my code is so long as it works?") but a geat deal of coding is about stucture. Proper indentation, consistent brace styles and the like all help to make that structure more obvious. Forgive me if some conversion-to-html-then-txt destroyed your already-perfect indentation, but looking at the kind of redundancy etc. that I reckon you would have spotted had your code been 'easy on the eye', I doubt it.
Another thing that makes code 'ugly' and hard-to-read is the mixing up of data and code, making it difficult to find specific parts of both. Here, your data is "print" statements containing (mainly) 'static' stuff. It's much more readable to have something like....
rather than...if ($something) { print $big_long_something_response; } else { print $other_big_long_string }
If you organised your code like this, you'd spot a lot of duplicated text ("This code copyright Pine Tree" etc.) that could be squirreled away (in "$copyright" for instance), making your intentions more obvious to yourself and others. In addition, the code would be easier to maintain, and you'd be more likely to spot structural errors /room for improvement.if ($something) { print "Something happened"; print "I could have defined this elsewhere in the file"; print "Or even used one of the fine templating modules..."; print "...available from a CPAN mirror near you..."; print "but instead I'm going to print 40 lines of code.."; print "and make this upcoming 'else' statement.."; print "really had to find without bracket bouncing all the time."; } else { print "you're going to have to bracket-bounce this one too.."; print "to skip what is basically a "do this or this" piece of code." +; . . }
Cheers, Ben.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
| A reply falls below the community's threshold of quality. You may see it by logging in. |