Re:Golden rules for becoming a better programmer
by falcolas on Tuesday January 26, 2016 @11:28PM
(#10978207)
Here's the easiest example I can come up with:
[ Parent
| on HN ]
Re:Golden rules for becoming a better programmer
by joshka on Tuesday January 26, 2016 @11:50PM
(#10978289)
how is this better than:
void DoActionOptimized() {
...
}
Re:Golden rules for becoming a better programmer
by codingdave on Wednesday January 27, 2016 @09:56AM
(#10980268)
Because at one point, the code was not optimized, so it already had a function name. Are you really going to rename all instances where that function is called so it is named based on a single commit, instead of its actual purpose?
Re:Golden rules for becoming a better programmer
by joshka on Wednesday January 27, 2016 @01:18PM
(#10981787)
There are many ways that are non breaking to implement this. I chose a particular one for example's sake. In reality, extracting an interface is a more valuable refactoring, and a likely valid one given that the optimization tradeoff is happening. So MemoryOptimizedFoo : IFoo, SpeedOptimizedFoo : IFoo...
Re:Golden rules for becoming a better programmer
by lomnakkus on Wednesday January 27, 2016 @05:41AM
(#10979350)
In fact you might also want the un-optimized code around and run the optimized version "against" the un-optimized version (in tests) to see if they actually do the same thing.
Re:Golden rules for becoming a better programmer
by joshka on Wednesday January 27, 2016 @01:10PM
(#10981722)
Extract an interface (IFoo). Implement Foo : IFoo and FasterFoo : IFoo. Write tests to confirm all implementations of IFoo act equivalently. Write performance characteristic tests around FasterFoo.
Re:Golden rules for becoming a better programmer
by lomnakkus on Friday January 29, 2016 @01:48PM
(#10997465)
Exactly.