Don't Prematurely Optimize your Sock Drawer

Background

In software engineering, we solve complex problems, and often have to consider factors such as how quickly our software will run, given some data. Say we are taking orders for a food delivery service, and we receive one order per minute. If our software can handle 10 orders per minute, there is no reason to try and make it faster; however, if we are only able to process one order every five minutes, we need to improve our process. This is a simple example. It's a common tendency for programmers to try and create extremely efficient systems on the first go, and often optimize without knowing the full problem.

The Socks Example

This is a problem nearly everyone has. You have a drawer of socks. You need to be able to put the socks in the drawer, which takes time, and you want to be able to get up in the morning, and find a matching pair quickly. Most people take each pair, tuck one inside the other, and put them in the drawer. This makes a lot of sense. You do some pre-processing, the tucking, and then when you are in need of a pair, it's trivial to find a matching pair. However, this pre-processing has time associated with it. If I have 10 socks, I have to tuck 5 times. If I have 100 socks, I have to tuck 50 times. This is a linear relationship. The more socks I have, the more tucks I have to perform. This is the best way of doing it...

The Catch

That is, unless you have prior information about the problem. It's easy to prematurely optimize the situation when you don't know the whole picture. Instead of having many kinds of socks, I have only one kind of socks. That means that any two socks I grab, I am guaranteed to form a match. I am frequently harassed by those around me for just jamming all my socks in the drawer with no order, but that's because I recognized that that extra work is irrelevant to the speed of my sock retrieval. Additionally, I completely avoid the tucking time.

Lessons Learned

When you think there's a right way of doing something, question it. Explore what you are gaining out of all of your habits. Often times, there are things that could be done just a little bit lazier, and save more time than they produce in value. Don't prematurely optimize your sock drawer.