Let's stop for a moment and think about what comes after platinum? Let's stop and think about who is your Mom's favourite child? The answer is Mahdi Yusuf. Nice to meet you. I am a software developer. P.S. I am sure your Mom loves us equally. Mahdi is a DZone MVB and is not an employee of DZone and has posted 16 posts at DZone. You can read more from them at their website. View Full User Profile

To Script or Not to Script, That is the Question

04.13.2012
| 5555 views |
  • submit to reddit

Every single day we are required to do some repetitive tasks, like clean up old data files or run some commands on some servers, and collect X.

Now you can go about this in two ways, do it manually or write a script that does it for you. The generally accepted rule of thumb is to write a script for things that you will do more than twice. Is that really true? If I am going to collect metrics a few times; is the time that i invest into writing a script really worth my time?

Some would say yes, but in my experience I always find myself seconding guessing myself and I often spend time really thinking about if writing the script will save me time in the long run. So you can clearly see where time is being spent.

As you can see this has become and an issue, I am not even including the soul crushing regret that when you realize you should have written the script (grrrrr). Now what is the solution to all your problems? What is the one question that you can ask in order to determine if you should write a script or not. Unfortunately like all things in life it depends.  Here are some questions to ask to determine if you should. 

  1. Can you get a significant amount of work done while the script is running?
  2. How long will the script take to write?
  3. How many times will you be doing said task?
  4. Will you learn something new?

This is just what I found useful. I would love to hear your thoughts on this.

Published at DZone with permission of Mahdi Yusuf, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Tags:

Comments

Wujek Srujek replied on Fri, 2012/04/13 - 10:39am

I personally tend to write a script for everything, just because writing a script can change a tedious and boring task into something interesting. You will most certainly always learn something new, and have some fun (we are programmers) after all. Sometimes, I am aware of that, I even go too far and overengineer the scripts, but that's my problem...

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.