Field Notes

When the Going Gets Tough, Change Layers

November 12, 2014 | In 30 days

A coworker looked in vain for a line of code. He knew a variable was being set somewhere, but couldn't locate it from the editor. I asked if he'd grepped for it from the command line. Lightbulb moment!

When a computing task is hard to do, it can be a signal to shift to a different layer of the stack.

Need to insert a row into table on create only but don't want to double your database queries? Add a trigger to the database.

The SQL query to stitch together two sets of data is a killer? Do it in Python after fetching it.

Too much data to handle on the client side? Preprocess it on the server and filter out the fields you don't need.

Angular's ng-mouseover causes too many digest cycles? Use jQuery to get the mouseover-goodness without alerting Angular. ( Thanks in advance to Aaron Frost. That will save my bacon some day.)

You need your huge input file to be in order with no repeats? Pipe the data files through sort | uniq .

Widen your gaze and look to your layers when the going gets tough.