Tip 27 in the book “The Pragmatic Programmer” says:
Don’t assume it – Prove it
This, to me, is the most important trait of a good programmer, or perhaps, a good knowledge worker at large.
When a bug occurs, the very first instinct of a Joe programmer is to jump in and fix it as soon as possible, and then come up with an assumption that he thinks is the solution.
Say, Joe gets some complaints from his customers saying that the web is too slow.
He assumes it must be the peak load that overwhelms the server, thus decides to scale up the server.
The next day, complaints don’t seem to go away.
Now it must be poor database queries, says Joe. Without verifying, he rewrites the query to use a cached version, deploys the “fix,” and marks the issue as resolved.
None of Joe’s “solutions” works.
It turns out that a third-party CDN serving images has degraded performance—publicly reported in their issue tracker.
The rule is simple: prove your assumption.
If you think your new queries are poorly written, then why didn’t other similar queries from the past slow the server down?
If you think it’s the peak load problem, try a load test and observe the results.
Why this failure wasn’t caught earlier? Are there any other places in the code that may be susceptible to this same bug?
The same principle should be applied in all areas in life that are not purely visceral (I doubt there is any, but let’s say, making up with your partner after a fight).
Example 1: You’re not feeling well lately
- Your assumption: it’s the air pollution.
- Your action: stay all day indoors.
- Your result: nothing changes
Actual cause: you’ve been eating a poor diet while working under high pressure.
Example 2: You get stuck in traffic every day going to work
- Your assumption: it’s the route
- Your action: change the route of your journey
- Result you get: go to work 5 minutes earlier
Actual cause: You go to work during rush hour; perhaps going to work 10 minutes earlier will save you 30 minutes on the road (”perhaps”, you need to prove it).
None of my examples above is absolutely the case, but the core principle is clear: without proof, everything is just an assumption. Sometimes the assumption is actually correct, but most of the time it is not.
Better said than done, it will take (me, at least) a great deal of time to get used to this habit of proving my assumptions.