Content

Good programming practices for web developers

Page is part of Articles in which you can submit an article

written by owen on 2004-Oct-30.

This is a down and dirty article directed mainly to PHP and ASP website programmers.

Project Scope

Keep the scope of your project in your head at all stages during the development projects. Try to keep everything dynamic, especially when you dealing with large amounts of data that will be difficult to change in the future. Small additions today may make it easier to add extra features in the furture. A program that is too static will make it impossible to adapt to future change. Sometimes you can keep it simple but it comes down to whether your going to save time now or save time later.

Client expectations

Clients can frequently cause unnescessary headaches for programmers working against a deadline. It is important to keep track of what they are doing and what they expect will be the end result. Use hand signals and charts if necessary.

Auto-Increment id for every table

Doesn't matter how small the table, how many columns or what keys your using - put a auto increment index column on the table. Do it, do it now! This will also be included in another upcoming article Good database design practices for web developers

Protect your data and validate

Worst case scenario all your data and all your tables get deleted from your database and you have no way of getting it back. Validate your user input. Create a few server-side functions so you can do it quickly and consistently across multiple websites.

Javascript is an after thought

After you finish adding you error checking you can add you javascript but otherwise leave it out. You site will work better in the long run and you'll have fewer bugs to worry about.

Common Functions

Make functions for you commonly used code and keep them consistent across all the websites you develop. It'll save you time and allow you to qiuckly update and improve your websites and programming habits.

Write your own code if you can

There is simply nothing like custom code, especially if your able to write it very quickly. You should be able to access, debug, and fix errors quickly without that clueless look on your face. If you use open source code make sure it's good code and you pay respect to the copyrights owners.

If you didn't write it don't mess with it

The first sign of doom occurs when you start to change something you downloaded off the internet. One change here, another there and soon you have a rogue app on your hands. Try to make as few changes as possible, so that you can upgrade to newer versions quickly and document these changes so that people can know what you added. If you have to make extensive changes then you should have written it yourself.

Test

Get somebody to test your application, you can't do it yourself.

Read

The Top Ten New Mistakes of Web Design

Anything I missed?

permanent link. Find similar posts in Articles.

comments

  1. I can't read other people's code, so all I have is my own. I am building my own library of commonly used functions, classes and regular expressions. Never trust user input. Last but not least keep names consistent (ie. same prefixes, same language, etc) and develop your own style and stick to it. If you code in the same style all the time, your development and debug times will go down. Not to mention constancy throughout all the pages.

    by Arie 2004-Oct-30 

  2. Owen,

    Nice article... looking forward to the next! I've recently started planning a CMS, and an trying desperately to research/document as much as I can before hitting the code.

    Any tips for moving forward on such a project?

    by Frank 2004-Nov-05 

  3. start out with a simple plan, build it and then make it complicated. A simple plan is key.

    by owen 2004-Nov-05 

  4. Good thoughts for new persons as well as experienced coders. Keep em comin..

    by Billerg 2004-Nov-13 

  5. Good article. I agree with a lot of it and I'm sure many persons will benefit.

    I disagree with the thing about changing other people's code. It is by standing on the shoulders of your peers that you progress, I don't believe in wheel reinvention (wheel improvement is so much better).

    I do most of my work with Python and Zope which means code is generally very easy to read.

    by pigeonflight 2004-Nov-17 

  6. I'm not sure I agree with the bit about Javascript. My manager's philosophy (which I have come to adopt) is to prevent the user from submitting erroneous data in the first place. Why have them fill out a long form, only to tell them after the submitt it that they can't? This works in our environment because we are running an intranet-based application and all our clients are using IE. In the bigger world out there, maybe your recommendation would hold, but I don't think its necessarily a rule.

    by nder 2004-Nov-17 

  7. Don't understand a thing but it sounds impressive. I wonder if I should do a course in Web designing.

    by Gelas words 2006-Jul-29 


comment