Hacker News new | ask | show | jobs
by shedside 3153 days ago
I'm curious about something. Why this:

  if shipping-method <> 'FX'
      move normal-ship-date-yyyymmdd to expected-shipping-date
  else
      move nextday-ship-date-yyyymmdd to expected-shipping-date.
And not the following?

  if shipping-method = 'FX'
      move nextday-ship-date-yyyymmdd to expected-shipping-date
  else
      move normal-ship-date-yyyymmdd to expected-shipping-date.
The latter seems clearer to me, and the line below (regarding the cust-type variable) suggests the syntax would be okay. It would also have the advantage of avoiding the column-length issue described in the post. What am I missing here?
2 comments

Probably taste: normal case first, special case last, regardless of what the respective comparison clauses look like.
Also efficiency, you want the most often true thing first. Although it is more important in nested if's. Had a colleague write a If else nested 104 levels deep (pre COBOL II so no case structure available). We halved the run time of the program simply by making the four most common conditions the first four.
I'm the author of the article, and to be honest the only reason I did it this way was to make sure the period ended up in column 73. I've presented this in talks about half a dozen times now, and you're the first person ever to notice that. Congrats!