3 ms·
Doesn’t “doing premature optimization” just mean “doing optimization before you ought to be,” and thus the phrase is a tautology if provided without any context
by baddox 9y ago
Doesn’t “doing premature optimization” just mean “doing optimization before you ought to be,” and thus the phrase is a tautology if provided without any context or explanation?
Obviously any useful advice isn’t just “don’t prematurely optimize,” but rather explains how to recognize premature optimization. I like the advice in this article to write things naturally until you have data that demonstrates that a refactor will improve performance.
Obviously experienced engineers will make deliberate optimizations up front without measuring. A great example is making sure your ORM uses a join instead of making N+1 queries: http://guides.rubyonrails.org/active_record_querying.html#eager-loading-associations http://guides.rubyonrails.org/active_record_querying.html#ea.... Yes, a small app could probably get away with N+1 queries for a long time, but I wouldn’t consider writing this properly to be a premature optimization.
- Silhouette 9y agoI suppose my point is that for applications where performance is a significant issue at all, there may be no useful interpretation of "premature optimisation". You have to design with at least the ability to code efficiently from the start, without relying on abstractions that hide performance traps. Otherwise you can back yourself into a corner where the only way out is to redesign or even entirely rewrite large parts of your code, and I think it would be generous to consider that sort of change a mere optimisation.