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.


In reply to Re: Does bad code really teach you to write good code? by TedPride
in thread Does bad code really teach you to write good code? by Gekitsuu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.