Subject: Re: [xsl] How to never make mistakes when coding? From: "Alan Painter alan.painter@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Sun, 2 Mar 2025 07:55:27 -0000 |
There is a foolproof way to avoid errors in code. Write no code. The frogs have a dictum, roughly: "Only people who do nothing make no mistakes." I personally adhere to the notion that keeping code clean and understandable makes it easier to avoid errors. Keep technical debt to a minimum. On Sun, Mar 2, 2025, 06:44 Joel Kalvesmaki director@xxxxxxxxxxxxx < xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > I assume that when I write code, I will make mistakes and lots of them. > I define mistakes as any discrepancy between what I mean versus what I > say. > > When you write code you always say what you say. That's inevitable. But > we don't always say what we mean. And it's critically important we find > ways to express our intent. > > Whenever I write an XSLT function or template mode, my first order of > business is to write lines of comment that express in regular prose what > I'm expecting in input, and what I'm expecting in my output, and a > description of edge cases, plus examples of input + output. > > Next, whenever I run into an XPath construct like the one you mentioned, > I bind it to a variable, whose name expresses my intention. Something > like > <xsl:variable name="post-initial-chapters" > select="//book/chapter[position() ge 1]"/> > In that construct it's much easier to identify my typo, because it's > bound to the variable name. Well, if it is "post-initial" how could it > ever be value 1? No guarantee I'll catch the problem, but almost always > it's easier to find the mistake later. > > Finally, as I write something I also develop a regression test library. > You can use XProc, Schematron, and a variety of technologies to do this, > really depends on the applications. But set these test suites up to > express your intentions. When a validation error strikes, those > expressions of intent will help you diagnose. > > I was once a music major, with a passionate interest in composition. My > music theory professor told us all (now deeply engraved on my heart), > "There are are only two types of people who write music in ink. Fools > and geniuses." > > It behooves us to code in pencil. > > > How to avoid making mistakes? Is it even possible? > > Joel > -- > Joel Kalvesmaki > Director, Text Alignment Network > http://textalign.net
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How to never make mistake, Joel Kalvesmaki dire | Thread | [xsl] XSL-List Guidelines, B Tommie Usdin btusd |
Re: [xsl] How to never make mistake, Joel Kalvesmaki dire | Date | [xsl] 10 reasons why I love coding, Roger L Costello cos |
Month |