IBMi RSS Feeds



Forget It! PDF Print E-mail
Tuesday, 30 August 2011 14:30

I've been in this business for over 26 years now, so there is a lot of junk in that attic that I call "brain". Hopefully, there are some useful items, too, but every now and again I remember something that I did "way back when" and realize that I'll never do that again. No, I'm not talking about things I did in college (it's even more important that others forget about some of those things). I'm talking about little tips and tricks that I've learned along the way.

Take date conversions. We have all had to deal with a date stored in a database as a numeric value. Sooner or later we need to convert it from one format to another. That's where that old trick of multiplying by a weird number and letting the system do truncation came into play. It was a cute (and very expensive) trick, always worked, but was oh, so esoteric. It's a good thing that I documented it in the code (at least once or twice). RPG-IV doesn't like that trick...without some extra effort. Using data structures or, better yet, date data types to do the conversion is pretty self-documenting.

If you're using any of these types of tricks, you're pretty clever, but not necessarily smart. Sooner or later you will need to mainatin that code. Or, worse yet, someone else will. Will you remember what you did and why? Will anyone else understand it? Friends don't let friends (or themselves) code cleverly...code it smartly. And, about those tricks: Forget It!

 

Comments  

 
0 # timothy R 2012-02-28 11:16
I agree. I work in a shop where an older database stores date values in dec(7,0). To help ease the pain of working with these columns in SQL we created functions to convert the date values to true date data types.

See below routine declarations:

fromXAdate(dec( 7,0)):date
toXAdate(date) :dec(7,0)
Reply | Reply with quote | Quote
 

ibm_i_rgb_white-backgrnd

GManTech Consulting, Powered by Joomla!