Coding & Debugging Workflow
I posted this in another thread but it's probably more suited to a thread of it's own in this forum.
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.
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 contiunung 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
Thank you for your help
I wanted to thank you for your first response to my request but could not find a way to respond. I just started using this forum and am still trying to navigate it.
Did you look at my website to see what I have accomplished? The page looks the way I want it presented but as I said earlier the code does not work. I copied this code from another website so I obviously have some background code that did not come with it. I assume I need to reference a clock of somewhere
Anyway I will try your debugging suggestion.
Nowadays or maybe I overlook, there is this thing called Test Driven Development. Basically the idea is you write Test Code BEFORE you write any application code. This is quite a drastic mindset shift from what we are accustomed to in software development isn't it ?
Example is you define your function interface input and then expected output FIRST. Then can you start building your internal application logic code. This reminds me of Java JUnit testing.
To be honest, I am still using tirna way of building small portions for test and then incrementally add on more code onwards until the whole application project wide hehehe...
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)