Archive for March, 2008

Best Programming Practises

Saturday, March 22nd, 2008

Recently I have gone through some of my old code and have found many programming nightmares. I, as with many other coders when starting out, tend to make the program work and care about practically nothing else.

I mean the client we are doing this for doesn’t ever see our code, so to them it all works fine. But….What happens when the client comes back and says “I need this changed”. And then you go back and think no big deal I just change this one SQL statement.

Then you go into your code and find this EXACT same SQL statement in many different places. Well now you need to copy and paste this into these areas. Well what happens if some error occurs with your replacements. Now the error could be anywhere.

Welcome to the horror of a programmer who needs to change code previously made by another programmer. What can you do you ask? Well the following are a few points that will help down the road.

  • Comment your Code – Remember that the code you write will most likely be touched by at least one other person in the future. Due to this you want to make your code as easy to understand as possible.
  • DRY (Don’t Repeat Yourself) – Use functions to put your code in one spot and then call the function from many different places.
  • OO (Object Orientation) – Make classes that can be reused in many applications and prevent you from writing the same code multiple times. This in turn will speed up your workflow and will help you turn around web apps quicker the next time around.
  • Frameworks (Symfony, CakePHP, RoR) – If the above sounds like a lot of work there are frameworks that help you do these different things. It helps you lay out your web app in a maintainable way that just takes a little learning of how the framework works.

I hope the above points you in the right direction and helps you become a better programmer :)

Please use our Contact Form if you have any comments or questions.

Posted in Uncategorized, Web Programming | 5 Comments »

Correct Mistaken URLS

Thursday, March 13th, 2008

Do your users ever make mistakes when they type in your URL? Well the majority of us know that they do. Your users are browsing your site at blazing speeds looking for something and once in a while a page will be misspelled.

An Apache module I found recently helps the user go to the correct page even if it is misspelled. The module is called mod_speling. It is very easy to use in that all you need is the module installed, and then somewhere in an .htaccess file you turn it on by using CheckSpelling On

It disregards the case, as well as allows up to one misspelling. If it determines that a page has one match it automatically redirects to that one. On the other hand if the page has a few matches it lists them for the user and then they can select the right one.

This is a great usability feature and prevents the user from always seeing the hated 404 error page. Some users when they see this immediately hit the back button and a potential sale is lost. Helping the user as much as possible is always a positive thing for your website.

Posted in Uncategorized | No Comments »

Web App Security

Monday, March 3rd, 2008

Currently, I am taking a course at school in regards to web application security. This is one topic I have avoided in most of my coding to date. I mean all of us know that programmers are lazy (including me) and we do things in the fastest way possible most of the time. I mean as long as something works you have done your job right? Well you have been mislead if that is the case.

The book we are taking is called Hacking Exposed – Web Applications. It has challenged me to think as a hacker would and hopefully prevent my code from being exploited.

Of course, 100% security is impossible on the web. If this was your goal the only solution is to take your site down. Things to be aware of is stuff like SQL Injections, Buffer Overflows, DoS (Denial of Service), and remote command execution.

Some general good countermeasures to these attacks are validate all input from a form, install the latest patches/fixes on the OS and Web Server, and close all ports that are not needed in order to run the site. Port scanning is a tool people use to see what ports you have open to attack them

There is obviously a lot more to security than this, but it gives you some do’s and don’ts.

Posted in Uncategorized | No Comments »

 
connect with me!