Code That Makes You Say… Huh? #1

Standard

Photo By Andyrob

Most of the work I do at my current job is maintenance to existing applications within my team.  A while ago I found an interesting line of code within a lotusscript library.

TStamp = Evaluate(“@Text(@Now)”)

It seems the developer that did this doesn’t know that there is a Now function in lotusscript.

I have found this same line in most of the applications that I maintain and I’ve also seen it in applications that I don’t maintain.  Worst of all, most of these applications are used globally and this line is used to capture the date and write it to an audit trail.  What’s wrong with this you ask?  Well you don’t have a consistent audit trail, for example the date format in the UK is not the same as in the US.

Two solutions to fix this would be:

  1. Make the audit trail date field a multi value date field and use the Now function to append the date value to the field.  With this approach you can use the field properties to adjust the format for displaying the dates.  This allows you to display the dates in the users local format or choose a specific format.
  2. Use the Format function in combination with the Now function to get the same date format everytime.  With this approach you ensure a consistent date format within the audit trail, but you loose the ability to display the dates in the users local format.

Have you found code that makes you say Huh in applications you maintain?

P.S. I’ve tried telling the developer that maintains the other applications to modify the code, but that’s another story…