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

This is something I think about quite a bit - I tend to do things haphazzardly. I learn best when I have an actual problem to solve. I can't just decide I want to learn about 'x' and then learn 'x' eaisly. Once I have purpouse I tend to Jump in head first w/o really knowing where Im heading with the code. I usually look at code Ive written in the past, to see how Ive solved similar problems, or I read snippets of others code - and somehow after reading tons of perl documentation, and re-writing I will wake up at 3am and it all seems so clear. For instance, I was recently porting a perl script which works on AIX to Linux, the original script contained tons of bad code to start with the original author did not use strict; or use warnings; I started there, once I added those and re-wrote this program of about 300 lines, and was not quite satisfied with it, but it worked - I woke up at two am and the words dispatch table popped into my head - I recoded the entire thing in like 70 lines, and it worked beautifully - I really didn't understand dispatch tables, but I remembered reading a node here recently, and knew that was my awnser, I re-read the node and it all just made sense - so to awnser your question, its more of a process for me, I need a goal and things that Ive learned or read about that were just beyond my grasp come into play - I want to say something now about the good code being the child of necessity or something corny like that, but Ill stop here, and leave well enough alone...

Ted
--
"That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved."
  --Ralph Waldo Emerson