J
John Carter
***********************
No virus was detected in the attachment no filename
Your mail has been scanned by InterScan MSS.
***********************
So the lack of static typing just bit me.
I had a bug, somehow the wrong value crept into an object, and somewhere
much later, my program died. This is _the_ nightmare scenario that grips
any static typer when he lets go of his static types.
Curiously enough in the year or so of slowly adding to this program, this was
the first time it really bit me. But then I tend to have fairly good Unit
Tests, so mostly such things get caught early.
But this one was evil, I had know idea at what level I had gone wrong. I
just had an error message "false::FalseClass does not respond to match".
So I found where that variable was set (in the constructor) and added...
raise "varX must respond to match" unless
@varX.respond_to? :match
And re-ran the program. It bombed out much sooner and the stack trace
showed me where it was called from. I then traced where that high level
variable was set (again a constructor) and added exactly the same line of
code.
Ran again and immediate found the bug. (I had added a parameter to a
constructor, and forgot to add it to the calling routing.)
I'm going to leave those "raise" statements in my code. I am still
the same stupid me, so I will probably make the same stupid mistake again
someday...
John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : (e-mail address removed)
New Zealand
The universe is absolutely plastered with the dashed lines exactly one
space long.
No virus was detected in the attachment no filename
Your mail has been scanned by InterScan MSS.
***********************
So the lack of static typing just bit me.
I had a bug, somehow the wrong value crept into an object, and somewhere
much later, my program died. This is _the_ nightmare scenario that grips
any static typer when he lets go of his static types.
Curiously enough in the year or so of slowly adding to this program, this was
the first time it really bit me. But then I tend to have fairly good Unit
Tests, so mostly such things get caught early.
But this one was evil, I had know idea at what level I had gone wrong. I
just had an error message "false::FalseClass does not respond to match".
So I found where that variable was set (in the constructor) and added...
raise "varX must respond to match" unless
@varX.respond_to? :match
And re-ran the program. It bombed out much sooner and the stack trace
showed me where it was called from. I then traced where that high level
variable was set (again a constructor) and added exactly the same line of
code.
Ran again and immediate found the bug. (I had added a parameter to a
constructor, and forgot to add it to the calling routing.)
I'm going to leave those "raise" statements in my code. I am still
the same stupid me, so I will probably make the same stupid mistake again
someday...
John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : (e-mail address removed)
New Zealand
The universe is absolutely plastered with the dashed lines exactly one
space long.