On the Virtue of Laziness in Software Engineering

Many years ago, I recall reading in an O’Relly book which stated that when it comes to programming, “laziness” is considered a virtue.

Be lazy, like this cheetah!

That may seem like a strange thing to utter, but hear me out. When working in software engineering, you will find yourself doing the same thing over and over. It can be tedious and mind-numbing, and if it’s the sort of thing that involves multiple steps, can increase the risk of human error. For example, one case of human error cost a company millions of dollars and ultimately tanked that company.

This means that the more things that are automated or at least semi-automated, the better. There will be less manual steps to run, and less things that can go wrong because a step was missed or not executed properly. Conversely, because automation means the same thing is done over and over, you’ll get repeatable builds which make things like troubleshooting, multi-tenancy, and disaster recovery easier to perform.

I’ll use myself as an example, and refer to a recent app I wrote, which could be used to Splunk venues in Yelp. The instructions on how to use it went like this:

# Clone the app
git clone git@github.com:dmuth/splunk-yelp-reviews.git

# Go into the app's directory
cd splunk-yelp-reviews/

# Install required Python modules
pip3 install -r ./requirements.txt

# Download some reviews. 
# Use another file containing Yelp reviews if you like.
./bin/download-reviews-from-url.sh ./urls.txt

# Start Splunk!
SPLUNK_START_ARGS=--accept-license ./bin/start.sh

That sort of sequence is fairly standard for a project, but there are several steps, such as requiring the user to clone the GitHub repository. If the person is new to software engineering or perhaps an analyst or a manager, that step may be challenging to them, and it conflicts with my goal of wanting as many people to use that product as possible.

So I created a Docker container which runs the Python code, some helper scripts to create and publish that container, and then a single script which does the above steps, though in a different way. The result is now a single command:

SPLUNK_START_ARGS=--accept-license \
   bash <(curl -s https://raw.githubusercontent.com/dmuth/splunk-yelp-reviews/master/go.sh) \
   ./urls.txt

Isn’t that so much nicer? Nowhere in where do you need to download a GitHub repo nor set up a Python environment. The latter is handled in a new Docker container, and the go.sh script performs some sanity checks for things like a URLs file. The end result is that several steps were boiled down to a single step. As a result, I’ve actually found myself using the software more, not less! It becomes that much easier for me to run that app against a new set of data, and Get Work Done.

And when you’re in an office or other professional environment, Getting Things Done is really what software engineering comes down to.

Here are some other things you can automate:

  • Standing up EC2 instances in AWS (whether with a script or Terraform)
  • Installation and configuration of software (possibly with Ansible)
  • Common system troubleshooting tasks (with a shell script or Ansible)
  • Health checking and diagnostics of a subsystem (like what I did with Docker)
  • Creating a Homebrew tap to automate installation of software written by yourself or others

Which of your processes can you automate or semi-automate today?