Anyone who has been programming for a while probably has written tons of code. For example, I began working with PHP somewhere in 2001-2002 I think. That’s 6 years ago.
As you can guess, I have written a lot of PHP code. I also happen to have some of my early works saved.
What does our old code tell us?
A newbie programmer
So as you can guess, I was quite a newbie back in the day, just like anyone was. Looking at my older code, I did have a solid understanding of the basic ideas, though: I had functions, a small attempt at templating and such. That was from around 2002-2003, at least according to my computer’s file creation dates.
I also had stumbled a bit with JavaScript back then, but I had mostly come to the conclusion that it sucks. Big time. That was actually half-true back then, at least in my opinion, as cross-browser JS support was much much worse than it is today.
Some of the more interesting old things I made was a simple modular CMS.
Anyways, the code I wrote was probably quite similar to what most PHP newbies write: HTML with PHP mixed in, and PHP with HTML mixed in.
A path to a better future
For someone like me who hasn’t actually had much theoretic programming / software design knowledge, it can be difficult to improve on some aspects of coding. Things such as best practices and how to write “good code” just don’t come to you right away – This is where formal education in software can help, as it often focuses on the theoretic side as well. Not very long ago, I hadn’t really heard about design patterns, for example.
Software design aspects are what you can learn from books, school and code. It does not come without practice, though. A fresh graduate might have the theoretical know-how but very little practical programming skills. Someone who has been programming for years on the other hand, should be able to easily grasp theoretical concepts and apply them in their work right away, becoming a better programmer almost instantly.
A track record
It is often very difficult to be critical of your current work – How would you know if it could be improved, if you just wrote it to the best of your abilities?
This is why I think you should keep old code lying around for a while. So you can come back to it a bit later, to see if it still makes sense to you, and to see how you’ve improved.
What you can learn from your older code is what you did wrong, so that you won’t repeat in the future.
What if your old code is like your newer code? Have you reached Level 1337 in programming? Unlikely. There’s so much to programming, that unless you’ve been writing code for tens of years and constantly improving your skills, there’s bound to be something you can do better.
For example, I have various files and looking at them I can clearly see how I’ve improved my coding practices. From the humble beginnings to today’s star programmer… or at least that’s what I like to think. There are phases where I haven’t improved much, but during the past years, I’ve read some software development books and worked on bigger projects than before. That teaches you discipline – when you just can’t throw in a function or two, as the whole package has to work properly and there’s a whole lot more involved in developing it.
Let’s keep improving our programming track records.
PS: Applies to many other things too, like blogging.