Wednesday, November 16, 2005

Code Obfuscation 101

Y = false && N = true

Sedulously eschew obfuscatory hyperverbosity and prolixity.

Here is one that is worthy of the "things not to do in ColdFusion" entries on the BlivitLog, I think.

In an application I'm working on, there is a piece of data supplied from a mainframe called ag2-sort-by-date. It's a single character long and can be supplied with either a 'Y' or an 'N'. So far, so good.

The problem arises when the logic behind the field is examined. If the value of the field is 'Y', then the items this field is referring to are sorted alphabetically, if the value is 'N', then the items are sorted by date.

Go figure.

So now, the question becomes: What do I do about it? This app round-trips to the mainframe, so the data has to get back there in the same shape or all sorts of nasty things happen.

  1. Use it as is. "We make bug hunting FUN!".

  2. Use it as is. Document it everywhere it pops up in the code and hope for the best.

  3. Flip the values at the first and last point of contact (on import and export). Might cause problems when talking to the mainframe group trying to debug.

  4. Other?

2 comments:

  1. You could also write a little cfx or something that translates the field to something more understandable, and always use that. Or create a data view (if that's possible in your mainframe) that translates it, and only use the view. Or find the original developer and give him a good </cf_whack> ;)

    ReplyDelete
  2. Haha. I like that </cf_whack> idea. I could see that coming in handy a lot.

    Seriously, though, I think I'm going to go with the flip at the import/export point option. At least then it winds up looking ok in my code. The web group and the mainframe group never understand each other anyway. This little issue will probably never come up. (or at least I'll be gone by then)

    ReplyDelete