views:

504

answers:

16

If you're doing some textual manipulation of a file/files, at what point do you decide to automate the process (using your favorite scripting language or writing a macro in a tool) ?

Is it after a certain number of repetitions or based on the likelihood you'll need to repeat the process ?

Is it productive to automate a task if creating the automation takes longer than completing the process by hand ?

+1  A: 

Quite simply. If it's quicker to do a one-off process manually, then I'll do it manually otherwise I'll write a script for it.

If I need to do it more than once then I will write a script for it.

GateKiller
A: 

Usually by the third time I do the same task, I'm ready to code up a solution.

Is it productive to automate a task if creating the automation takes longer than completing the process by hand ?

If it's worth automatic at all, most likely yes. Like any other accounting question, figure your break-even point, and judge for yourself.

Greg Hurlman
+1  A: 

If I'm doing something for the second time, I consider automating the entire job or at least a part of it.

The third time, I slap myself.

dustinupdyke
+2  A: 

Depends on boredom.

I tend to find those kind of side task relaxing when I'm in a stressful situation and I've been working on boring stuff all day long. I will also over engineer them for added fun.

Coincoin
+13  A: 

I'll generally write a tool if I expect that it will take me longer than about five minutes to make the change by hand, or if I expect that I'll be doing it much more in the future (maybe 3 or more times, roughly).

I'll often do this even if it will be slightly faster to just do it by hand. I do this for two reasons.

  1. I often end up needing to do it again anyway, even if I didn't expect it originally.
  2. I'm happier if I'm not doing mindless data formatting, and keeping me happy keeps me more productive.

(Blocking access to Stack Overflow would probably also make me more productive lately.)

Derek Park
A: 

I think any repetitive task lends itself to automation.

So, if I find myself doing similar text editing or manipulating data more than an handful of times and I have a lot more stuff to go through before I finish, I would take up the task of automating it using a quick Ruby or Python script.

Is it productive to automate a task if creating the automation takes longer than completing > the process by hand ?

Yes, in some cases. If you think that the task that you want to automate will show up sometime in the near future, it would be handy to have a utility written earlier, so that you can finish it now without wasting more time on it.

Pascal
A: 

Waay too low.

If it can be automated then I'll find it more interesting to automate, even if it wouldn't have taken that long in the first place :-/

Keith
+7  A: 

I think the mark of a true programmer is that you have at some point spent more time writing a tool to automate a process that you would have spent doing the same process manually

Jason
+5  A: 

From Pragmatic Project Automation:

The simple answer is that you should apply automation whenever you've grown tired of doing something manually. Some folks have higher boredom thresholds than others. As a rule of thumb, manual procedures that will be run more than twice should be automated. Odds are the third time won't be the last.

Patrick McElhaney
+2  A: 

I try to find tools that make automation an afterthought. The interactive Python Shell makes automation super easy and with CLR integration I find myself able to create disposable (I think of them as disposable but more often than not I find myself going back to the same things over and over) utilities quite easily.

I think a question that should accompany this is what tools make automation an afterthought? Some things that come to mind for me:

  • An interactive shell for programming
  • A nice text editor
  • A tool that stores code snippets

Anything else?

David in Dakota
A: 

At about 3 consecutive changes I will probably write some code to automate it for me, not only because it is less mentally taxing, but because if I do the same thing more than a few times, I will be more likely to screw it up and have to go back and fix it. So I would say go ahead and write the tool, because no matter how long it takes to write, it will probably save you time in the long run.

Brad Gilbert
A: 

Anything past one change, and I'll try to use a regular expression.

I've also been known to write tools to handle entire files of a specific type.

Ryan Fox
A: 

If it's repetitive and easy to automate I automate. I have 3 levels of automation. If it's text editing I will do a macro. My next level is scripting using perl, python, vbscript, or powershell. The final level is actually writing a program and usually the only reason I go to this level is performance.

My threshold for writing a macro is pretty low. Doing the same kind of edit to 15 lines or so is macro time for me. I like tools like TextPad that make it easy to create scratch macros by learning your keystrokes. You can then use the macro and throw it away. If I know I'll use the macro again I'll give it a name and save it.

bruceatk
+1  A: 

I've found that once you write a tool to automate something, you instantly become the only person in your organization that can do the task. Oh, and don't even bother trying to give your tool to others and teaching them how to use it; they'll only come back with feature requests!

In all seriousness, I find that the odds of me writing a tool doesn't solely depend on how often I have to perform the task, but also how many steps are in the task. My last script really wasn't about me being lazy and trying to save time; if you have a task with a lot of steps, you're likely to forget something. For me, a lot of tasks involve doing something on every server in the cluster. Without tools, I would often forget about one of the servers and I'd wind up with 2 different versions of something out in the wild.

Outlaw Programmer
A: 

It's all about the errors, depending on the cost/quality desires of the current task. Particularly in high-volume situations, where you won't simple "notice" an error in output.

Automation saves time, yes, but it is also wonderful for removing human error. When I worked in data entry, I learned that human errors led to unacceptable poor-quality data in the end.

Because we did not use automation, we had to invest extra time checking every single thing that was done.

Then again, if you're only doing the one image at a time, e.g. lolcats, you don't have to worry about errors because you will notice them.

A: 

If it takes you 5 minutes to do by hand, or 10 minutes to code, then you should code it if you know you'll need to do it 2 or more times.

OR

If you want someone else to be able to do it instead of you, then code it.

lo_fye