Timeline for Clean readable code vs fast hard to read code. When to cross the line?
Current License: CC BY-SA 3.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 9, 2020 at 10:18 | comment | added | Marco Pallante | @Evgeni: I would separate code interface from its implementation. Two different implementations for the same interface (.h/.c, interface/class, it depends on the language you're using). Then switching from first impl. to second should be a matter of relinking or rerunning your code. No rename involved, more clean to me. | |
| Nov 16, 2014 at 18:18 | comment | added | user1852503 | @Paul if you are doing that might be a good idea to fail the test if the optimized version is ever slower than the ref function. this can happen if the assumptions you made to make it go faster are no longer true. | |
| Oct 9, 2013 at 14:52 | comment | added | Paul R |
@Eugene: I usually keep the original version of a routine named foo and rename it foo_ref - typically it lives immediately above foo in the source file. In my test harness I call foo and foo_ref for validation and relative performance measurement.
|
|
| Oct 9, 2013 at 14:29 | comment | added | Evgeni | @PaulR How do you keep that code ? In form of comments ? That is wrong, imo - comments get outdated, nobody reads them, and personally if I see commented out code I usually remove it - this is what source control is for. A comment on a method explaining what it does is better, imo. | |
| Jul 17, 2011 at 15:49 | vote | accept | Ken Cochrane | ||
| Jul 5, 2011 at 7:05 | comment | added | Paul R | You also make sure you keep the original, slower, cleaner code, both as a reference implementation and to fall back on when the hardware changes and your faster, hackier code no longer works. | |
| Jul 5, 2011 at 2:14 | history | answered | Norman Ramsey | CC BY-SA 3.0 |