917.848.7284Data for Finance and Accounting


Report Writing Tip – The Evils of Hard Coding

Report Writing Tip – The Evils of Hard Coding

If you?ve ever been around developers you may have heard of the term ?hard coding.? Hard coding is the enemy of self-sustaining reports – this seemingly fast and simple solution can often wind up being ultimately slow and expensive.

Imagine a company – Acme Stuffed Animal Corp. – which sells all kinds of stuffed animals. One day Sue, the Sales Manager, comes in to visit Pam, the Programmer. Sue needs a Commissions Report – she wants a report which groups sales by lions, tigers and bears. Oh my. Additionally, Sue is running a special promotion for her sales team and wants sales of lions to receive a 5% commission, sales of tigers a 4% commission and bears a 3% commission. There?s no database in which they store such information, but she nevertheless needs the report right away. Sue also indicates that this will be a ?one time? report – once this promotion is over, commissions will go back to a straight percentage calculation on sales of all animals.

So Pam starts to type some simple code: If (Item group = Lion then commission = sales *5%)… The report is done quickly, Sue is happy and assures Pam that she won’t need to touch this again.

Except, she does. The next month, Sue wants amphibians added to the report – frogs, toads and salamanders. The month following, it’s reptiles – iguanas, turtles, alligators and crocodiles. And then the month after that all the commission rates change…

Because Pam hard coded the report, there?s no way for Sue to modify it on her own. So every time Sue the Sales Manager wants the report changed, Pam the Programmer needs to be involved. Either Sue doesn’t get the information in a timely manner or Pam?s other work get’s delayed. Meanwhile the program itself becomes more and more of a mess. This is the evil of hard coding.

Now, what if Pam took time at the beginning to build a simple screen and database uniting Animal Type and Commission? Nothing would be hard coded ? Sue, or any other user, would simply update the information and run the report. It may have taken a bit more time at the beginning of the process, but it would have made things run more smoothly, given the end user control of the report, and saved a great deal of time in the long run.

My advice: Avoid hard coding whenever possible.


No Comments

Post a Comment