Bengt Mårtensson > Private Site
Font size:      

Miscellaneous stuff

Here are some random ramblings on different themes. The inclusion of a matter here does not mean that I consider it more important than issues not covered here.

Revision history

2005-05-23 Initial version.
2009-07-19 Renamed from "likes-dislikes" to "misc" (directory). Reorganized. Removed link; it is no longer pertinent in that the sillyness it argues against is hardly found any more (goal achieved!). Removed link to due to insufficient up-to-dateness. Added, ternary operator.


Other Items

  • The ternary operator (like in days == leapyear ? 366 : 365) is often frown upon, and considered as bad programming style by some individuals or style guides. However, as this Wikipedia article shows, when used properly, the ternary operator is very helpful to write logical, redundancy free code, producing better and more maintainable code than when avoiding it. My dress code is, if I have a meeting, then tie, otherwise jeans is actually better than If I have a meeting, then my dresscode is tie, otherwise my dress code is jeans, since the latter is redundant ("my dresscode is" is duplicated), and the exterior if-clause hides the ultimate purpose, namely to select a dress code, not to perform different actions depending on whether a meeting occurs or not.
  • For many of us who are forced to work with MSDOS or Windows, the selection of the path-component separator, the backslash character "\", is a never ending source of annoyance, since it violates the established semantics of that character, e.g. within the C programming language, see Wikipedia. This note contains a plausible explanation.