|
|
somebody wrote:
> I think the best "trick" is to use a programming language which was designed
> with at least some forethought, so that such tricks are unnecessary.
Heh.
To answer the original question, check out the book "programming pearls".
I do the (0 == X) and it seems quite natural after a time. (And I
occasionally get asked why I do such things in languages where
assignment and equality don't get mixed up, like Tcl. :-)
I also do the "never use the > sign" in comparisons. It's not a question
of how you read it out loud, but a question of putting the things in the
right order. For example:
0 < A & A < B
If A is between zero and B.
A < B | C < A
If A is outside the range B to C.
if (start + 300 < now)
If now is at least 300 seconds past when we started.
Start putting in complicated timestamp calculations, and it becomes very
helpful. Always use < or <=, always add rather than subtract offsets,
and I almost never make a mistake and get the wrong things being compared.
It's kind of like drawing a picture, rather than writing a sentence.
IME, most programmers are more visual than auditory.
--
Darren New / San Diego, CA, USA (PST)
"That's pretty. Where's that?"
"It's the Age of Channelwood."
"We should go there on vacation some time."
Post a reply to this message
|
|