4 ms·
I think every program should be sliced like this and not doing so is a programming mistake. Of course, Im talking before bottlenecks optimization.
by quadcore 9y ago
I think every program should be sliced like this and not doing so is a programming mistake. Of course, Im talking before bottlenecks optimization.
- CogitoCogito 9y agoI 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).