Some things I've noticed:
- Whitespace has become something I'm almost religious about.
- Same for indentation. (Is there a difference?)
- The more I code the smaller each discrete piece becomes, even to the point of being only a few lines.
- I've started writing bits of code I know I'll use over and over again (or don't want to keep coding out each time I need) as stand-alone functions/procedures to be called as needed.
- I've now officially reused code from another of my projects.
- Comments have become much more frequent and structured. If there's anything even vaguely cryptic it comes with a comment. Significant blocks of code come with comments.
- I tag the start and end loops and conditionals with numbered comments to help me keep track of them (this is in addition to whitespace and indentation).
- I version my software, but I'm not yet to the point of using a versioning system like svn.
Most of this has come about because of my couple of somewhat coding intensive research projects. Two summers ago I wrote a couple thousand lines of SAS code to process a dataset and over the last 7 months I've written a few hundred lines to do some computational geometry and statistics in R. Just looking back at my own code has taught me how annoying poorly written code can be.
No comments:
Post a Comment