in reply to Avoiding silly programming mistakes
A lesson learned as a result of being bitten sticks much more readily than one learned as a theoretical precaution. Here are two cases in point:
sub foo { my $arg = shift; # ... } vs sub bar { my ($arg) = @_; # ... }
I started using the second construct because adding additional parameters only requires me to change the LHS. I had got bitten enough times to warrant the change.
if ($foo == 0) { # ... } vs if (0 == $foo) { # ... }
The reason some people recommend the latter is because if you accidently type the == equality operator as the = assignment operator, you will get an error (not so for the former). Since I vary rarely get bitten by this, I still use the former.
In a nutshell, there is no substitute for experience. The gray area becomes how much needs to come from your own personal experience or how much you can learn from someone else's experience. I recommend reading Re: Refactoring a large script and adopting any advice there that you don't currently use. Share what common mistakes you make and ask around what methods others use to avoid them. Share what you have come up with on your own so that others can benefit.
Cheers - L~R
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Avoiding silly programming mistakes
by missingthepoint (Friar) on Aug 21, 2008 at 11:27 UTC | |
Re^2: Avoiding silly programming mistakes
by JavaFan (Canon) on Aug 20, 2008 at 13:35 UTC | |
by Limbic~Region (Chancellor) on Aug 20, 2008 at 13:56 UTC | |
by moritz (Cardinal) on Aug 20, 2008 at 14:04 UTC | |
by JavaFan (Canon) on Aug 20, 2008 at 14:11 UTC | |
by Limbic~Region (Chancellor) on Aug 20, 2008 at 14:48 UTC | |
by Jenda (Abbot) on Aug 29, 2008 at 16:33 UTC | |
by kyle (Abbot) on Aug 29, 2008 at 17:56 UTC |