Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-26-2011, 02:22 AM   PM User | #1
bullant
Banned

 
Join Date: Feb 2011
Posts: 2,699
Thanks: 13
Thanked 395 Times in 395 Posts
bullant is on a distinguished road
Coding and Debugging Workflow

Some Basic Debugging 101

This is just food for thought and a brief summary of my general coding workflow. This applies to both Javascript and PHP

**** Code a little and test a lot ****

In my experience many programmers, especially early on, code the whole script from go to whoa without doing any testing along the way and since most times it won't work first time, they then get in a knot trying to work out what is wrong.

I prefer to code a few lines and then test that code to ensure it works. That way if something goes wrong I am debugging only a small chunk of code and not a whole script.

Example:

When I start a PHP script to process form data one of the first things I do is get the data from the form and store it in variables.

Before I do anything else I then display the received form data on the screen using echo. If the form data hasn't come across correctly there is no point in proceeding with coding the rest of the php script.

Then if I have to insert or retrieve any records from a database I write that small block of code and check any inputs or outputs before proceeding because, again, if they are not correct there is no point in contiuning to code the rest of the script.

So if you continue coding and testing in small chunks you are much more likely to have a properly working script when you get to the end.

Debugging in small chunks is much easier, imo, than trying to debug a whole script, especially if you are not sure what is causing the error in the first place.

Anyway, the above is just food for thought

Last edited by bullant; 04-26-2011 at 07:56 AM..
bullant is offline   Reply With Quote
Old 04-28-2011, 01:26 AM   PM User | #2
ckdoublenecks
New Coder

 
Join Date: Jun 2010
Posts: 60
Thanks: 4
Thanked 0 Times in 0 Posts
ckdoublenecks is an unknown quantity at this point
you're right of course. this was working until I decided to get the taxrate from a separate table instead of hard coding it in. I've just fought this for awhile and I thought I'd ask. thanks.
ckdoublenecks is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:54 AM.


Advertisement
Log in to turn off these ads.