Tuesday, August 25, 2009

When to automate, abstract, generalize?

When you have a repetitive task to perform, at what point is it worth it to write a script to automate the task? When is it appropriate to abstract away the details? When should you write one highly parametrized function, and when should you write several specialized functions?

More importantly, how should you go about answering these questions beforehand so that you don't go down the wrong (i.e. inefficient) path?

At a conference a couple years ago I attended a talk that addressed some of these questions, but I do not really remember much about it...

I found myself dealing with all of these questions today. I had written some highly parametrized Verilog modules, but it was very tedious to support each variation. Furthermore, I ran into a bug in the simulator (described at the end of my next post), and I decided to circumvent the bug by splitting each module into a few specialized modules. I was then faced with the tedious task of factoring each module into its specialized variants, so I decided to write some elisp to do it for me.

So, in the end I found that I had made the wrong decision to implement parametrized modules, though I could not have predicted the ridiculous bug that I ran into and so was justified in the decision. I feel like writing the elisp to automate the rewrites of each module saved a lot of time, but I cannot really be sure.
Reblog this post [with Zemanta]

No comments:

Post a Comment