Best Coding Practices

By Marc Plotz

I have probably read about 100 articles about the best coding proctices of one language or another all talking about what to do or what not to do when actually developing some sort of application or website. However, I have found myself devising other practices as I progressed--things that not only make sense to me, but work well, are within the norms of standard coding practices and do not break any rules. The problem is that these things I have found along the way are things I have never seen taught anywhere.

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.

  1. 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.

    Planning is essential, and something I do not see mentioned as a best coding practice anywhere.
  2. 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.

    A PHP developer who does not know the difference between PHP 4 and PHP 5 is a developer who will not get hired. A JavaScript developer who does not know what a DOM is is in the same boat. Make it your aim to know everything about your trade, and implement what you know. your code will not only work, it will shine.

  3. 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 conclusion

There 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

Make a Comment

Loading Comments...

  • Web Development Newsletter Signup

    Invalid email
    You have successfuly registered to our newsletter.
  •