Subject: Re: [xsl] How to never make mistakes when coding? From: "Jean-Luc Chevillard jeanluc.chevillard@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Sat, 1 Mar 2025 17:01:51 -0000 |
Hi Folks,
A few days ago I found a mistake in my code. The input data to my code contained a sequence of records and my code should iterate over all the records after the first record. I wrote this:
<xsl:for-each select="/root/record[position() gt 2">
See the mistake?
I should have written position() ge 2 or position() gt 1
That mistake had been in my code for weeks. It was only a few days ago that I accidentally discovered it.
"How could I have made such a simple, basic mistake? Was it a lapse in attention? I asked myself.
How to avoid making mistakes? Is it even possible?
One part of me thinks, "You are human. Humans make mistakes. It's part of our psychological makeup. Accept that you will always make mistakes. The remedy for mistakes is to find good ways--testing, validation--to identify the mistakes and then fix them."
I don't like that. I'm an optimist--if there's a problem, then there's a solution.
Perhaps if I had extreme discipline, then I could have mistake-free code? Perhaps if I had no mental lapses when coding, then I could have mistake-free code? Perhaps if I adhered rigorously to some programming practice (e.g., literate programming), then I could have mistake-free code?
Perhaps if I had a tool that generates code, then I could have mistake-free code?
Perhaps code that is rooted in algorithms--do step 1, then step 2, then step3, etc.--will always lead to code with mistakes? Perhaps the declarative approach--state what is, not how to do it--is the path to mistake-free code?
Have you thought about these types of questions? What answers did you come up with?
/Roger
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] How to never make mistakes wh, Roger L Costello cos | Thread | Re: [xsl] How to never make mistake, Roger L Costello cos |
[xsl] How to never make mistakes wh, Roger L Costello cos | Date | Re: [xsl] How to never make mistake, Roger L Costello cos |
Month |