June 05, 2020 • 4 min read
Also known as the Law of Economy or Law of Parsimony, it can be expressed in a few different ways
Given two competing theories, the simpler one should be preferred
and
Entities are not to be multiplied beyond necessity
If you ever have a moment when you think to yourself, “Hmm, something just doesn’t make sense”.
Try again. You haven’t abstracted the problem enough.
You’re on AirBnb looking for a place to stay and message a few listings to see what your options are. You go through the effort of writing yourself a function to create a message based on the few variables you care about - rooms, beds, and people
def request_message(people, rooms, beds):
return "Hello,\
I'd like to book your AirBnb.\
We'll have #{people} people coming.\
Just wanted to confirm we'd all fit comfortably.\
#{beds} beds across the #{rooms} rooms, correct?\
- Francisco"You send out five requests
airbnb_listing_a.send_message(request_message(4, 8, 10))
airbnb_listing_b.send_message(request_message(5, 7, 10))
...
airbnb_listing_e.send_message(request_message(5, 5, 10))You get automated responses from listings A and B. Excited to finally be done with the search process you open the message and to your surprise they’re the exact same response. You double-check the realtors, their names are different A' and B'.
The first assumption you made about them being different people comes into question.
What are the odds that two different people took the time to set up automated messaging and arrived at the exact same message? It’s possible, but really unlikely?
You apply Occam’s Razor knowing there is a simpler solution.
Adding a layer of abstraction, you consider it might be a single realtor that owns both listings. Something still doesn’t make sense. It’s as if they spent all the time to write up the message
def automated_response(rooms=4, beds=8, people):
return "Hello, \
We'd love to host you!\
The place has #{rooms} rooms.\
#{people} people fit comfortably in the #{beds}.\
- You'll love it!"but gave up right at the end and just copy paste
airbnb_listing_a.set_automated_response(automated_response(4, 8, 10))
airbnb_listing_b.set_automated_response(automated_response(4, 8, 10))Again, you question your assumptions. Maybe it’s not a single realtor.
Why would a single person go through all the trouble to make two AirBnb accounts, set up an automated response, but forget the final touch?
You apply Occam’s Razor knowing there is a simpler solution.
The realtor owns at least two homes, so you can assume he’s wealthy. Knowing that wealth compounds continuously, odds are good that: given he owns two homes, he owns more than two.
It’s conceivable he’s so wealthy it’s not worth his time to add an automated response to all of them and added a layer of abstraction to outsource the work to an intern.
He doesn’t trust the intern to write the message because a poorly worded message would cause him to lose business and quickly creates automated_response himself and passes it to an intern.
The intern, nervous about messing up, asks the realtor for some guidance getting started.
The realtor, not realizing it’s the interns first job, shows him step by step by example
airbnb.comairbnb_listing_aairbnb_listing_a.set_automated_responseautomated_response(4, 8, 10)The intern - does exactly that.
Each listing ends up with an automated message of automated_response(4, 8, 10).
The realtor gave him a function. He didn’t teach him how to use a function.
As always, there’s a perfectly rational explanation and again all is right in the world.
Written by
Knowledge makes the world go round, share yours