I think you answered my question, but I see, in reading my post, that I didn't cover everything I intended in my question.
For example, neither of those docs really explains to the novice programmer the value of code modularization. I'm not just referring to placing reused code in a library. Even within one script, you'll often see people write a subroutine that is named something like "&get_grades" and when you look at the subroutine, it will have all sorts of functionality not related to getting the scores.
Let's say the &get_grades subroutine takes two arguments: the student and the class. One thing we might want to do is verify that the person running the script has the right to view those grades. Oftimes, you'll see such validation occur directly in the &get_grades subroutine. It really doesn't belong there as it is not directly related to the function of that subroutine. The authorization should probably take place before the subroutine call, or the &get_grades should call another subroutine like &verify_access_rights. That's second nature to many of us, but may not be immediately obvious to the novice.
Another issue would be code optimization. For many common functions, there are a lot of things we can do to optimize the code. In my orginal post, I mentioned the difference between
and$array[$index++] = $_;
The second version is preferable in terms of optimization. Regexes are another great area where common optimization rules can be grouped and demonstrated. For example, virtually everyone knows that $` is a bad thing. But, how many people really pay attention to /o and /i switches? <CODE> while (<>)push (@array, $_);
In reply to RE: RE: Good coding practices
by Ovid
in thread Good coding practices
by Ovid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |