Friday, June 15, 2007

Consistent Efficiency Is Key

Task:

  • Find today's calendar period starting and ending date, where if the starting date is the 1st then the ending date should be the 15th, and if the starting date is the 16th then the ending date should be the last date of the month.

Short of writing the date with a string, which of the two following methods demonstrates a clear logical thought? (Disregarding the conciseness of the code).

Method #1:

method1 

Method #2:

method2 

When seen from the biggest picture, i.e., a total development project cost (and/or tco) of $1, the two methods above demonstrate a difference between:

  • Getting much less value of the $1 payout albeit with a lot of code line count (and a potential debugging and maintenance nightmare); versus,
  • Getting much more value from the $1 payout including clarity of thought, code conciseness, ease-of-debugging and most neglected value of all savings in maintenance cost.