WILD ARTIST All about LIFE

21Oct/09

Mission! Remove duplications!

It's one of the most annoying circumstance to do something TWICE. Doing the same work wastes time and money. It's really a problem that many ongoing projects have such bottle-neck-maker problems still unknown. It can be applied to both the mechanism and application system itself. Then I want to cover the issue today which deters the process.

twins

Resembling problem are the most frequently approached case. What if both things are similar each other but little different? I like to write script code which fulfills the task automatically but sometimes it can't. Once I'd got a same code block spreaded in various files and should modify something in the block, I integrated the block in a file and made refered files to include it. As you know, there're various solutions case by case. The duplication problem can be divided into two categories: task dup and data dup. And here are the solutions I like the most.

Task dup
Task dup comes from misunderstanding or misleading. The case that someone misunderstands the requirement in accurate is a good example. I suggest three-step method to deal with this kind of duplication.

  1. How to avoid? Should totally understand the problem, that is, should know the problem correctly.
  2. How to deal with it? If the amount is big, try to automate to do such a task.
  3. How to crack it? Record the reason and educate employees about the accident.

Data dup
Most data dup are trivial troubles. Script will help you. If paper record instead of electronic data is on the rise, no automatical way available. I can only show you an example of script-solved problem.

Example Case) A normal salary man John is working as an accountant. His daily work is to record finance many clients defray. One day, around the time to leave the office, he noticed that he'd got a mistake of inputting the client code incorrectly (he added 1 to all of the codes). So he asked his co-worker Ted, a good scripter, to modify mis-coded data automatically. Ted simply made a script for him as below.

def convert_client_code( miscode, other_args ):
    if miscode > 0:
        miscode = miscode + 1 
        # record the code into a file in a format