3 ms·
I think this point may be one of the most important in all programming. Taking the example from the wikipedia article (i.e. https://en.wikipedia.org/wiki/Progra
by CogitoCogito 9y ago
I think this point may be one of the most important in all programming. Taking the example from the wikipedia article (i.e. https://en.wikipedia.org/wiki/Program_slicing#Example https://en.wikipedia.org/wiki/Program_slicing#Example ), I think the correct way to program this is with the sum and product loops separate. The only reason to combine them is if it is a bottleneck as you say. Across a code-base there will be very few places were most time is taken and it is there that these optimizations should occur. Everywhere else it should be separate because that optimizes for code clarity. Always engage in cognitive optimizations first and speed/resource/architecture/etc. optimization second (and even then _only_ if necessary).