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 which captures the optimization decisions. Can't do that in CeePlusPlus
. -- JamesCrook
'Simple' optimizations are done automagically by compilers.
Complex optimizations often require radical rework of code.
Optimization 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 optimizations orthogonally to the actual code. Ability to specify functions as 'inline' and compiler switches such as optimize for speed/space are the only two examples that spring to mind. Until compilers expose their optimization techniques to users better, it will be very hard to implement optimization 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.