http://qs321.pair.com?node_id=59365


in reply to Random thoughts on programming

  1. If you think you need to optimize, always profile your code first. Use Devel::Dprof for perl scripts, DBIx::Profile for DBI code, Apache::Dprof for mod_perl apps.
  2. Explore, Learn and Study CPAN. Look often at the recent uploads list. You never know when a module will come out that will allow you to re-factor out code from existing systems. Remember, even the most brilliant people understood the value of learning from those who came before:

    "If I have seen further it is by standing on ye shoulders of Giants." --Isaac Newton Feb 5, 1676

  3. Look at the source code of the CPAN modules you use. Worst case, you will learn some interesting uses for perl, best case you'll learn more efficient ways to use those common modules you thought you knew everything about.
  4. Format and comment your code as if you are going to return to it later for instruction. File the location of this code in your memory (or better yet docs), because if you need to do something similar you have a pre-existing code base. Learn to bootstrap your future development using custom made documentation and examples.
  5. Find a good text editor. Learn it well.
  6. Get involved in PerlMonks.
  7. The teacher will sometimes learn more than the student. By trying to explain a concept to another person, it's like you're learning it all over again.
  8. Keep everything as simple as possible. Write the least amount of code to get the job done. Just given the law of averages your likelyhood of making mistakes goes down. Besides that, the less you need to keep in your head at once, the more likely you are to understand the bigger picture.
  9. Understanding needs to come before automation, otherwise you will be doomed to solve your problem again, and duplicate the effort to re-automate it. I always solve the problem proceduraly before making objects, keep paper records before making a database, and design interfaces in HTML before making CGI's. Even though this doesn't always return perfect results, IMHO I believe the answer I come up with is usually closer to the ideal than without this methodolgy.
  • Comment on (dkubb) Re: (2) Random thoughts on programming