http://qs1969.pair.com?node_id=11140523


in reply to Re: Perl Contempt in My Workplace
in thread Perl Contempt in My Workplace

Whenever I have an opportunity to mentor people in writing code, I tell them about this habit I've had ever since I became a reasonably good Perl programmer:

Every time you open a new, empty file that will contain source code, the first thing you should write into that file is commentary: a description of what this chunk of source code is supposed to do; its inputs and outputs; a synopsis of its usage and (where appropriate) an explanation of its default and optional behaviors. (Doing this as POD is the Best Thing Ever.)

Don't start writing the actual code until that part is done. (If, as the code gets written, you change your mind about anything, update the description accordingly.)

I've found myself repeatedly relying on this habit when it comes to being able to quickly grok code that I wrote years ago, or months ago, or just last week. It's also very helpful in keeping things clear in my head as I work on the code I'm writing this week.