Linked by MOS6510 on Wed 17th Apr 2013 21:20 UTC
General Development "You often hear about how important it is to write 'readable code'. Developers have pretty strong opinions about what makes code more readable. The more senior the developer, the stronger the opinion. But, have you ever stopped to think about what really makes code readable?"
Permalink for comment 559195
To read all comments associated with this story, please click here.
RE: Comment by lucas_maximus
by hhas on Thu 18th Apr 2013 22:47 UTC in reply to "Comment by lucas_maximus"
hhas
Member since:
2006-11-28

Sorry if someone has a problem understanding what a whole number is, they shouldn't be programming.


Actually, the fact that NumberOfCoins is declared as an Integer is itself outright misleading: it should actually be a whole number (i.e. an integer with a minimum value of zero and no upper bound) since you can't hold negative coinage in your pocket but in theory could have any number above that (tho' the US Mint and laws of physics might put a practical cap on that eventually).

(Also, I strongly believe any C*/Java developer who bangs on about the vast importance of Integer and Float needs to be locked in a room full of Type theorists and Haskell and Eiffel programmers until they learn what a real type system is.>:)


As for should or shouldn't be 'programming', there are lots of folks in the world who'd recognize the term 'number' or 'whole number' a lot easier than 'integer'. Consider any spreadsheet user, for example: they might be a domain expert in finance and accounting, but they're not what you'd call a 'conventional' programmer by any measure. For them, they don't care what a cell's 'type' is called, only that its contents adhere to their required rules and holds its exact value 100% reliably at all times.

While you're at it, consider the fundamental difficulty, not to mention overt danger, of handing Floating Point types to such users. Especially those that deal with precision-critical tasks like money management, where Very Important Folks like shareholders and IRS might not be so happy to take "just some FP rounding errors" as an excuse.

Frankly the only thing nastier than dealing with numbers in a computer program is dealing with text as (contrary to traditional programmer beliefs:) most of the planet does not speak ASCII, and many of those middle- and far-east scripts are crazy hard to handle correctly, and even quite unexotic ones can have a few nasty tricks up their sleeves.


So, y'know, while it's easy to say "Integer or GTFO", being able to recall what 'integer' means is only a small first step down the actual rabbit hole - and I think even experienced developers may easily overlook just how deep the devil really goes.

Reply Parent Score: 2