Programming style/habbitsHow do YOU do it?
42 Replies - 4952 Views - Last Post: 05 April 2008 - 10:40 PM
#1
Programming style/habbits
Posted 19 March 2008 - 07:02 AM
Me, I compile often. I also test often. I would say that probably about 10% of the code I write is purely for testing purposes and will not appear in the final product.
Now I realize that I am not a fast programmer and a good deal of that is probably related to the fact that I have a very conservative programming style (referring to how I work not my coding style). I am wondering if I am the norm or the exception. It would seem to me that other programmers are much faster -- and I think part of that has to be that they don't "waste" as much time writing code to ensure that the other code that they have written works.
How often do you compile the code you are working on?
How much do you test as you go?
Replies To: Programming style/habbits
#2
Re: Programming style/habbits
Posted 19 March 2008 - 07:10 AM
Seems to me it saves time and energy in the long run to test functionality often rather than get to the end and lose hours trying to find a missed quotation mark.
I also usually have DIC open in my Firefox window... 1. for when I need a quick break, 2. for when I need a quick reference, and 3. for when I need to post a question. I must say I am so happy to have found this site - you all have saved my butt on more than one occasion.
This post has been edited by BenignDesign: 19 March 2008 - 07:14 AM
#3
Re: Programming style/habbits
Posted 19 March 2008 - 07:25 AM
#4
Re: Programming style/habbits
Posted 19 March 2008 - 07:33 AM
BenignDesign, on 19 Mar, 2008 - 07:10 AM, said:
I usually do this when I'm working on XHTML, using Firefox + Safari - in addition to that, my editor(Smultron) has an in-editor preview, so I can just push cmd+u to preview the HTML document.
For a language that actually needs compiling/testing, I'm usually doing a compile/test after any significant change, whatever that may be for the given project.
#5
Re: Programming style/habbits
Posted 19 March 2008 - 07:44 AM
To explain what I mean by this I will give an example: In a recent POC (proof of concept) I had to write a class that would write auditing information to a database. Now the only requirement was that entries get written -- since it is a POC and not a solution the code was never expected to function past testing. BUT I went ahead and added other functions to update entries, to delete entries, to delete old entries etc. -- a complete auditing class. Nice to have, but now I have a class where only about 20-25% of the code was actually used/required.
I understand that sticking to the requirements document is important since "added functionality" leads to support problems later. But I can't help it, when I am building a class I tend to add in all the functions I think that Object needs.
#6
Re: Programming style/habbits
Posted 19 March 2008 - 07:48 AM
Initially when I started out, I used to test only when I wrote major chunks of code but it led to solid debugging sessions so now I compile as often as I can.
#7
Re: Programming style/habbits
Posted 19 March 2008 - 07:57 AM
- I am quite confident in my coding
- every modern IDE does syntax highlighting so an obvious syntax error becomes visible right on the spot
- the applications I work on right now rebuild in a minute, and the initialization and startup takes at least twice as much time, so it is not that exciting (in the other room there is a monster, that rebuilds in 15 to 20 minutes)
- usually the test cases and functions I have to go through take even longer to test, so it is not really efficient to compile and test too frequently.
Anyway, this is why we like unit tests, don't we?
Back to your original question, I find it strange too, that people post codes full of syntax errors, because the compilers usually give quite good error messages recently (not like the javascript errors of IE), so they should not be too hard to fix.
However you can still read my answer as I compile and test as much as I can.
#8
Re: Programming style/habbits
Posted 19 March 2008 - 08:17 AM
This post has been edited by tody4me: 19 March 2008 - 08:17 AM
#9
Re: Programming style/habbits
Posted 19 March 2008 - 09:02 AM
#10
Re: Programming style/habbits
Posted 19 March 2008 - 09:19 AM
#11
Re: Programming style/habbits
Posted 19 March 2008 - 11:23 AM
Quote
#12
Re: Programming style/habbits
Posted 19 March 2008 - 11:40 AM
Even in the C#/VB.Net forums I see people constantly posting code that, with a single look, you can see it wont work, and is normally the cause of their initial problem. When answering in the forums at times I'm guilty of writing solutions in Notepad, but for the most part I actually test the code I'm offering as a solution.
Even with the tutorials I write, the code is written in Visual Studio and tested before posting the tutorial.
Though I am very confident of my coding abilities, I will continue to do my unit tests and user testing just to ensure that I can catch as many of the errors as humanly possible before sending to QA. With the web application I'm currently working on I use my family for user testing as well, I tend to like to have non techies test my work when I think it's completed, as a programmer knows all too well how to find the "happy path", whereas end users will always find a bug if it exists.
#13
Re: Programming style/habbits
Posted 19 March 2008 - 12:27 PM
#14
Re: Programming style/habbits
Posted 19 March 2008 - 01:43 PM
1lacca, on 19 Mar, 2008 - 11:02 AM, said:
I know, it's not the normal coding practice, nor is it a good one, but I'm also not in a normal programming role where specs are actually fully defined. Usually my specs are something like "can you try to give me this information from this table". To which I write a program to give reports, or lookups.
This post has been edited by tody4me: 19 March 2008 - 01:44 PM
#15
Re: Programming style/habbits
Posted 19 March 2008 - 01:46 PM
Then once I know how to do it, I'll write out the whole damn thing, all of it. That's when I mentally switch from "programming mode" to "debug" mode, and that's when I do my first upload.
For debugging I'll first scan for the obvious --- mismatched quotes, unclosed curly braces, missing semicolons --- really just the parse errors.
From there, I search for the more complex. Things like missing $ in variable names can trip a script up! I'll open up phpMyAdmin to see what all my script is doing. My codes generally have loads of "if" statements, maybe it's just habit, maybe they all are necessary. I comment out the redirects, and then put in "benchmarks" --- inside each if statement I'll throw in an echo of what it's doing and compare that to what's going on. Any parts giving me trouble I look at closely.
When debugging I shift my mindset, and then reupload after every little change, rather than almost never.
This post has been edited by spearfish: 19 March 2008 - 01:48 PM
|
|

New Topic/Question
Reply



MultiQuote










|