Best Coding Practices
In this article I will attempt to advise you on three simple things that should help you to become a better developer, regardless of your language of choice. Do not expect to get any coding tricks or clever ways of taking shortcuts here. This article will show you things that you probably already have thought of, and if you have, and have not implemented them, perhaps it's now time to start wondering why you haven't.
- Design Before You Code - Irrespective of how complicated or intricate the project is that you are working on, design is crucial. If you have, at any time during the development of a project, smacked your palm against your forehead in realization that you will need to rebuild half of your application because you overlooked one crucial thing right at the beginning, you will appreciate this piece of advice.
It may be a bit extreme, but when I start a new project I generally do a wireframe sketch of every page, including all of the functionality that could possibly exist on that page, and then I look at how clicking or submitting anything on that page will affect anything on that page or anything else on any other page. I can promise you that by the time I have done that there is nothing about the project that I do not understand or is not clear in my mind.
So, generally, I take a day to plan the project, and I have learned that it saves about a week of development time simply by doing that. Recently I built four similar projects from one such wireframe design that took me a week to complete. However, thereafter I completed all four projects in half the time it would have taken to complete one, simply because I planned everything properly.
- Know Your Oats - Let's face it: you are a professional developer, right? Or, if not yet a professional, you surely would like to be one? The very fact that you are here reading is probably a good pointer to the fact that you would like to, or at least are interested, in improving your work. As you know, a doctor keeps studying new medicines, reading new material and researching new techniques almost daily, in order to stay at the top of their game.
So, being a developer / programmer / coder--whatever you would like to call yourself, you need to constantly improve and better your coding style, technique, and technologies. You need to know what is the best way to do something--simple or not--and you might get a big surprise realising that the way you have been doing something is not necessarily the right way. Try to know everything, or as least as much as is possible, about what you are doing. Not only is this going to make you an awesome developer, it will really allow you to have the power to know what you can and cannot do with your code, and it will allow you to know the simplest, best and safest way of doing it.
- Validate Regularly - Whatever markup language you use, there is a validator out there for it. Use it. Validating your code will not only kill most or all of the browser incompatibility issues involved, it will also make your work display as intended. Be sure to validate your work as you go and repair any errors or warnings that the validator spits out. Code that validates properly works properly. It's that simple.
In conclusionThere is no sure way to go regarding your work ethics, and indeed, work ethics are something that a developer does need to possess. I have worked with far too many people who code by the seat of their pants. The problem is that a week later they are rewriting the code becuse it did not work. Making clear decisions on how to implement a procedure or structural change or implementation on a project knowing ALL of the variables, consequences and problems that could evolve during the implementation will not only save you time, energy, and a few buckets of blood, sweat and tears--people will start calling you AWESOME when your projects work right off the bat, and look great too. Think about it.
Until next time,
Marc Steven Plotz