SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Non-Member Kalon's Avatar
    Join Date
    Aug 2010
    Location
    At my computer
    Posts
    2,012
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Coding and Debugging Workflow

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

    A wise person once told me

    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 continuing 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, imho, 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 and happy coding

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,139
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    Testing is really just part of good work flow to hopefully avoid bugs or catch them before they can propagate. Debugging is its own, separate process.

  3. #3
    Non-Member Kalon's Avatar
    Join Date
    Aug 2010
    Location
    At my computer
    Posts
    2,012
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I suppose it depends on your definition of debugging and testing.

    while testing, if an error (bug) is found then fixing it is debugging imho.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •