Make it work first, before you make it work fast
, attributed to Bruce Whiteside in 'More Programming Pearls' Jon Bentley ISBN 0-201-11889-0
Quoted here not
to plug 'OptimizeLater
', rather as an illustration that optimization is or can be a separate design task.
The page OptimizationPattern
give some methods for optimizing. What I am looking for is how to factor out optimization. If in CategoryCpp
, we'd be looking for a class that captures the optimization decisions. We can't do that in CeePlusPlus
. -- JamesCrook
'Simple' optimisations are done automagically by compilers.
Complex optimisations often require radical rework of code.
Optimisation is not currently as useful a 'factor' as it could be. Implementation languages let us down.
Orthodox computer languages lack a flexible way to specify optimisations orthogonally to the actual code. Ability to specify functions as 'inline' and compiler switches such as optimise for speed/space are the only two examples that spring to mind. Until compilers expose their optimisation techniques to users better, it will be very hard to implement optimisation as a factor.
In design documentation, optimizations can (and should?) be design topics in their own right. You can understand the purpose and structure of a program without understanding the details of optimization choices that have been made and vice versa. If designers routinely treat optimization as a design topic, language designers will in time follow up with language support.
How this could work
There are at least two optimizations which have very widespread applicability:
With language support for these factors, optimization could more easily be a design task independent of the main design.