Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

My first contractor gig was to add some functionality to a document processing script.

First time I was programming in the scripting language, but after reading the docs to grok the syntax and standard library apis and a repl to test out code snippets, I was good to go.

I open the script.

If you've ever transferred a CRLF-delimited text file to a UNIX-like OS and back, you know what I saw.

The script alternated between code and blank lines. Someone had committed the code after some tool somewhere along the way did a CRLF->LFLF->CRLFCRLF roundtrip.

And no one decided to bite the bullet and cleanup the mess.

Sigh.

After spending a couple of days to get the script running on test documents and understanding the code flow, I discovered two things:

1 - a coder had inserted a one minute sleep() call delay into the script (so the script's output could be checked?) That coder committed the change which was rolled out into production!

2 - the script had two large if statements, each several hundreds of lines long. There were a handful of differences in the two if statements - took me at least half a day to confirm that there were only a handful of trivial differences.

I removed the sleep call and refactored the two if statements into two function calls with the few variable arguments required and created one function to handle the functionality of those two large if statements.

I also removed all the extraneous blank lines.

In the end:

- reduced the script's line count by 75% (half the lines were blank, consolidated the two large if statements into one function and invoked the function 2x)

- reduced the runtime by one minute per document processed

The company didn't believe me when I mentioned the sleep() call in the script. I had to open the script on the production box and show them the sleep() call.

I committed my refactored script and got assigned to another project.

One year later, I ask how the new script was doing in production.

The people responsible for the daily monitoring of the document processing say that they're still using the old script.

Oh.

That's nice.

I hope they took out the one minute sleep() call at least.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: