PC Pro Magazine

“There was some date-checking going on–presumably to stop you entering a year during the Black Death”

Writing good code is hard. As the old joke goes: if it were easy, everyone would be doing it. Part of writing good code is defining the use cases, the allowable input data and the expected output ranges. At the lab, we’re heavy users of conditional cell formats in Excel: define an acceptable range for a result and highlight it if it goes out of range. It may not be perfect, but it can make it obvious that something is wrong, either due to a typo or an unexpected but correct input.

Indeed, I’d go so far as to say that any sort of numerical handling in an app or spreadsheet should be liberally smothered with appropriate handling and highlighting. It should be part of the basic techniques that we learn when we start on our coding journey. I’d even say that a modern spreadsheet should start with all cells locked, and you’re only allowed to unlock cells for data entry when you have predefined acceptable ranges for the data. It might sound clumsy in a “throw it into Excel and munge the numbers” world, but you only need to look at recent handling of government Covid data (see Steve’s column on p120) to know where this ends up if you’re not careful.

Any sort of code evaluation should include such checks. This can be for code injection, buffer overrun issues and all other sorts of coding unpleasantness. But also just for the expected input range and output values

You’re reading a preview, subscribe to read more.

More from PC Pro Magazine

PC Pro Magazine8 min readSecurity
How To Earn Cyber Essentials Certification
If your business has any kind of internet connection, it’s at risk. In a recent survey by Deloitte, a full third of executives said their accounting and financial data had been targeted over the past 12 months; in 2022, an incredible three-quarters o
PC Pro Magazine14 min read
Slash Your Bills Build Your Own Smart Home Grid
The standard electricity tariff in the UK is still an eye-watering 28p per kilowatt hour. In February, by “gaming” the variable price tariff he’s on and making the most efficient use of the solar panels and batteries in his home, PC Pro reader Rob Tw
PC Pro Magazine6 min read
Readers’ Comments
Editor-in-chief Tim Danton writes: A huge thanks to everyone who wrote in about their mini PC experience in response to my request last month. Sadly we don’t have space to include all the responses, but I’m grateful to Jeffrey Barfield, David Forth a

Related Books & Audiobooks