|Problems? Is your data what you think it is?|
On Testing and Formatting Codeby jcwren (Prior)
|on Oct 03, 2000 at 20:34 UTC||Need Help??|
I've actually been wondering about this for a while, but a back'n'forth between merlyn and myself in regards to Using formats for 2-columnprinting made me want to pursue this.
Before I post any code, I test it. I do this for two reasons, the primary one being that I am not so good that I can just "wing it". Oh, sure, a print statement or something is easy, but for *anything* that involves a regex, I test it. I have to, or I'll look dumber than usual when it doesn't work. The other reason is a matter of personal pride. I like code that works. I'm embarrased when I write code that doesn't, and frankly, I don't like to feel embarrased. Pride in workmanship kinda thing, I guess (It may not be pretty, but by Dog, it WILL work!)
I am not criticizing people that don't test. Mind you, in the Using formats for 2-columnprinting, merlyn said from the start that it was untested "except in his head" (and I still want to know what version he's running...). I cut'n'pasted the code mostly because it didn't have a 'use strict'. To be honest, I'm very suspect of code that doesn't, and I like to see if it will actually run or not. In this case, a little back and forth determined that our local wizard had forgotten/didn't know that @### combined with ~~ wouldn't work together.
Which brings me to my main point. How many of you that post code actually run it (presuming that it's not disclaimered)? How many of you can't resist reformatting someone elses code when you do post it? (Me, I hate opening braces on the same line as a statement. It's gotta come underneath the verb). I also put a space between a function and it's paranthesis, but no space between the paran, and it's argument.
Looking back through a few posts where I've posted code, I see that I almost always "touch" it to make it more readable, as I define readable. I see a few other people that do that, also. I find this rather amusing, in some ways, like we either are so abhorred by the way it looks we must change it, or we have to "brand" it with our style.
What are your opinions? What do you do? And how many of you try out the code that people post here, whether it's full blown applications, or two line fragments?