Best Programming Practises

 

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.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Add to favorites
  • Design Float
  • DZone
  • email
  • FriendFeed
  • PDF
  • Propeller
  • Reddit
  • RSS
  • StumbleUpon
  • Twitter

Related posts:

  1. Web Application Hacking Exposed
  2. CodeIgniter PHP Framework
  3. Correct Mistaken URLS
  4. Debugging: The most important tool in your toolbox


Written by Brenley Dueck

 

5 Responses to “Best Programming Practises”

  1. George Entenman Says:

    October 18th, 2008 at 8:20 am

    It’s also a good practiCe to run your web pages through a spell checker.

  2. Anonymous Says:

    October 18th, 2008 at 10:23 am

    Nice and succinct article!

  3. John Rockefeller Says:

    October 18th, 2008 at 8:26 pm

    “Me, as with many other coders when starting out, tend to…” should read
    “I, as with many other coders when starting out, tend to…”

  4. prashant Says:

    October 20th, 2008 at 11:41 am

    Nice blog.Mainly it is very imp to comment your code especially if you are like me maintaining other’s code. ;-)

    Thanks
    prashant
    http://www.prashantjalasutram.blogspot.com

  5. admin Says:

    October 20th, 2008 at 11:43 am

    I’m glad you liked the blog entry.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 
connect with me!