On 29 May 2013, at 14:14, Oleg Krupnov <oleg.krup...@gmail.com> wrote:

> While I generally agree that premature optimization is evil,

That seems to come out of a belief that well-structured code is code that runs 
poorly (this belief came out of an IBM system of the 50s/60s that had really 
poorly running subroutine calls - so the recommendation was not to structure 
things).

In one sense I think we should always be optimizing code. That is in the sense 
that we write well structured and correct code. Usually optimization naturally 
follows. There seems to be a school of thought that writing poorly structured 
code must be optimized, but I have usually seen that most badly running code is 
a result of poor structure and refactoring makes it both structured and 
optimized. Once you have got to such a structured state then you might be able 
to see where further optimizations can be made to profiled areas of code which 
might result in more complex, but still structured and optimized. Where 
something simple is replaced by a more complex algorithm it should be well 
documented.

That is the subject of Dijkstra's book "A Discipline of Programming". Once a 
well-structured algorithm is developed, better optimizations can then be seen. 
This is the 'engineering' part of software development - making software run 
practically (not the drawing diagrams part). For particular computations (that 
is where the algorithm works on particular data sets), an algorithm might not 
be optimal, so needs to cater to those cases.

In summary - we should be producing well-structured code early on. This will 
usually result in well-optimized code. However, this is not a guarantee and 
particular cases may need to be addressed later (that is the premature 
optimization case). But we should always aim to produce well-structured code.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to