β When to Optimise
Most code doesnβt require optimisation. And time taken to optimise code could often be better spent elsewhere: refining the user experience, adding new features, or improving security.
As Donald Knuth (never actually) said:
Premature optimisation is the root of all evil!
Not all optimisation is inherently bad. But the tendency to optimise too early, or in places where itβs not needed, can create more problems than it solves.
The most effective way to approach optimisation is to do so only when there is a clear, measurable performance issue that impacts the user experience, system reliability, product functionality, or cost.
So before thinking about how to optimise your code, ask yourself the following questions:
- Does the code work?
- Does the code conform to team standards?
- Is the code robust/tested?
- Does it really need optimisation?