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 559247
To read all comments associated with this story, please click here.
RE[3]: Comment by lucas_maximus
by hhas on Fri 19th Apr 2013 12:22 UTC in reply to "RE[2]: Comment by lucas_maximus"
hhas
Member since:
2006-11-28

"since you can't hold negative coinage in your pocket


No, but you could be in debt.
"

Do not mistake Coins, which are shiny pieces of metal of various shapes and sizes, with Money, which is an abstract concept, frequently overdrawn.

Oh sure, if one really insists one can always write stuff like:

int NumberOfCoins = 5;
int DaylightRobbery = -5;
NumberOfCoins = NumberOfCoins + DaylightRobbery;

But then I wouldn't blame either the language nor the reader, but the smarmy smartass that wrote it - because that's exactly the sort of rotten communication skills that rightly give practitioners a bad name.

As for dealing with money, I still wouldn't want to type it as Integer or Decimal (and definitely never Float). I'd declare my own Money type or Dollar type or whatever was the most descriptive name appropriate to the task and then use that. That clearly describes my intent in creating that variable and properly decouples my own program logic from underlying hardware/language implementation.


BTW, this is why I've grown a tad contemptuous of C*/Java type systems and the folk who hold them up as the One True Way Typing Should Be Done. Compared to the sorts of types systems you can find in functional and other 'exotic' languages, C*/Java typing is downright crude in concept and execution, limited in its expressiveness and mindlessly bureaucratic to use.

A good type system ought to be a positive productivity tool for expressing your program's intent as effectively and efficiently as possible. But too often C*/Java typing is used as a personal crutch for lazy thinking, sloppy coding, premature 'optimization' and OCD tendencies: negative programming habits blessed with official seal of approval. Such a mismatch/shortfall is not only a technical deficiency but a cultural one as well. My earlier (long) post has more discussion of why cultural problems are every bit as important as - and fundamentally inseparable from - the technical ones, so I'll not repeat it here.

Reply Parent Score: 2