in reply to Does bad code really teach you to write good code?

You can't fully understand and appreciate good code without having written bad code first. Your mind only remembers what is useful to you, and an answer to a problem that you haven't run into yet isn't going to stay with you long. I often write answers to SoPW questions that have been answered already so I can compare my code to the posted solutions. I just have to be careful not to post my code unless it will add to the discussion.

Even better than reading good code, however, is getting comments back on your own code, bad or otherwise. There's almost always a simpler, easier, more efficient way to solve a particular problem. Whenever possible without being annoying, submit your code for review. New SoPW questions are good for this, once you get past the basic newbie barriers of learning how to use strict, use warnings, use CGI (and other basic modules that everyone should use in the proper situations, like Digest::MD5), and how to manage references and nested data structures. When I first joined PM, I didn't know a lot of this stuff, and I imagine I annoyed a lot of people by posting my solutions with global variables and subs for processing form data and so on. My algorithms were good, but my code was crap.

  • Comment on Re: Does bad code really teach you to write good code?

Replies are listed 'Best First'.
Re^2: Does bad code really teach you to write good code?
by Gekitsuu (Scribe) on Jun 18, 2005 at 07:05 UTC
    Unfortunately most of the code I write is confidential by contract :( I have started working on some projects on my own at home but they are far from ready for scrutiny. I do believe what you say is true that getting feedback is an important part of learning. I feel that discussion is one of the best things life has to offer and enjoy hearing from my peers.