Feeds

Postconditionality is dangerous to your English

You are an erudite lot

SANS - Survey on application security programs

In my recent piece on M and Mumps I included a throwaway remark on “post conditionality”, which has generated some correspondence. Here’s an example in M, courtesy of my M-speaking correspondent, Tommy Martin:

S:X=5 Y="TEST" S:$D(Y) Z="ALPHA" I A=2 D SUB


SET if X=5 Y="TEST" SET if Y exists in any form Z="ALPHA" IF A=2 DO the SUB subroutine

(The execution continues to the end of the line, but if you used IF statements, fall through would occur. See also here.)

Lots of you (too many to cite individually) have pointed out that you can do something a lot like this in Ruby, Perl and other languages, too. For example:

# Perl

print "hello\n" if $foo eq $bar;

Although - in the spirit of Lewis Carroll's Humpty Dumpty, who chose what his words meant - the Mumps standardisers seem to have rather plucked the term “post conditionality” out of the air, Ruby, for example, considers it to represent a “statement modifier”.

And Reg Developer columnist Kevlin Henney confirms that this isn’t an obscure feature. “A number of scripting languages have it, plus a couple of statically typed ones - it's just that you won't find it in C, FORTRAN, Java, COBOL, etc...” Well, exactly, the ones that don’t have it are just the sort of languages that I and, I suspect, Tommy Martin are most familiar with - although I have met something like it when I played with Ada years ago (thanks, Kevlin, for the syntax):

loop

...

exit when foo > bar;

...

end loop;

But hold on a minute, surely where you put the IF statement, while significant in practice, is rather a trivial issue? I thought that “post conditions” were really all about “design by contract”:

• Preconditions — what must be true when a method is invoked

• Postconditions — what must be true after a method completes successfully

This is much more important as it gives you a powerful way to minimise bugs in your programs by, in effect, testing your assumptions about the way your application and its environment works. (Kevlin has discussed Design by Contract in a recent Reg Developer article here.). And you can do this informally (with some caveats) even in Java, using “assertions ” to test postconditions etc.

You might, for example, test your “postcondition” assumption that an array contains the same contents (after it has undergone some supposedly non-destructive manipulation) as it had to start with, using assertions - with apologies to “design by contract” gurus – this is only an informal programming style, not the real thing. Similar facilities are also available in C and C++ through the assert macro and in C# with Debug.Assert.

So, are we, in fact, confusing two different things? I think so because, as Kevlin points out to me, “the term 'postconditionality' is a little confusing because it implies it is something to do with pre- and postconditions…” Well, quite.

What we have here, it seems to me, is sloppy use of English by the standards police, or, perhaps, unfamiliarity with all of the computer science theory that is supposed to underlie what we are doing. After all, we know that the laws of computer science are regularly repealed by Moore’s Law (do something wrong and it won’t matter in a few months when CPU’s get faster), don’t we? So, surely we can just use any names that seem relevant to what we doing at the time, without regard to any other meanings they might have?

Well, up to a point, Lord Copper, in both cases. Humpty Dumpty could say: “When I use a word it means just what I choose it to mean – neither more nor less, but programmers don’t have that luxury.

This may be a deeply sad admission, but I once defined all the words in Structured English in a data dictionary so I could automate, in part, QA of our minispecs. Just as code has to be precise and unambiguous, so should the English terms used to describe programming constructs be precise and unambiguous – as should also the TLAs we use so freely, as well as, of course, the English we use to describe user requirements. If we don't use English properly it may be as fatal to our applications as a failure to use, say, Java properly. But perhaps it is already too late…? ®

David Norfolk is the author of IT Governance, published by Thorogood. More details here.

High performance access to file storage

More from The Register

next story
This time it's 'Personal': new Office 365 sub covers just two devices
Redmond also brings Office into Google's back yard
Oh no, Joe: WinPhone users already griping over 8.1 mega-update
Hang on. Which bit of Developer Preview don't you understand?
Microsoft lobs pre-release Windows Phone 8.1 at devs who dare
App makers can load it before anyone else, but if they do they're stuck with it
Half of Twitter's 'active users' are SILENT STALKERS
Nearly 50% have NEVER tweeted a word
Internet-of-stuff startup dumps NoSQL for ... SQL?
NoSQL taste great at first but lacks proper nutrients, says startup cloud whiz
IRS boss on XP migration: 'Classic fix the airplane while you're flying it attempt'
Plus: Condoleezza Rice at Dropbox 'maybe she can find ... weapons of mass destruction'
Ditch the sync, paddle in the Streem: Upstart offers syncless sharing
Upload, delete and carry on sharing afterwards?
New Facebook phone app allows you to stalk your mates
Nearby Friends feature goes live in a few weeks
Microsoft TIER SMEAR changes app prices whether devs ask or not
Some go up, some go down, Redmond goes silent
prev story

Whitepapers

Securing web applications made simple and scalable
In this whitepaper learn how automated security testing can provide a simple and scalable way to protect your web applications.
3 Big data security analytics techniques
Applying these Big Data security analytics techniques can help you make your business safer by detecting attacks early, before significant damage is done.
The benefits of software based PBX
Why you should break free from your proprietary PBX and how to leverage your existing server hardware.
Top three mobile application threats
Learn about three of the top mobile application security threats facing businesses today and recommendations on how to mitigate the risk.
Combat fraud and increase customer satisfaction
Based on their experience using HP ArcSight Enterprise Security Manager for IT security operations, Finansbank moved to HP ArcSight ESM for fraud management.