How to convince 'performance guys' to Clean Code

238 views
Skip to first unread message

Dariusz Tryba

unread,
Jul 18, 2013, 4:38:04 AM7/18/13
to clean-code...@googlegroups.com
Hello!

I would like to introduce Clean Code principles to my team, but I know that they (as C++ machine vision, close to hardware programmers) will argue about performance in case of having many small functions.

What would you do? 

Do you have any additional arguments or maybe some hard evidence about performance before / after refactoring.

Just saying that Uncle Bob said "memory is cheap" and "it's a case of nanoseconds" may not be enough for me.

Uncle Bob

unread,
Jul 18, 2013, 11:01:44 AM7/18/13
to clean-code...@googlegroups.com
Measure. Measure. Measure.  Write a module both ways and measure the differences.  Use the cleaner approach in those cases where the difference in insignificant.  

The best procedure is probably:

First make it work (get tests to pass).
Then make it right (clean it).
Then make it fast. (if it needs it).  

Use a profiler or some kind of measurement tool to prove that a module isn't fast enough before you make it faster.  

Philip Schwarz

unread,
Jul 19, 2013, 2:57:38 PM7/19/13
to clean-code...@googlegroups.com
Should be of interest: Optimizing for code readability vs efficiency - Google Groups
https://groups.google.com/forum/m/#!topic/software_craftsmanship/YRUAFCANDMw

Philip

Philip Markgraf

unread,
Jul 22, 2013, 5:04:25 PM7/22/13
to clean-code...@googlegroups.com
Check the assembly being generated (and tweak your optimization settings to get this right). Since the bulk of the small functions extracted are private and in the same code file, the compiler can easily inline the many small functions into the outward facing public function. Therefore, the many small functions may have no impact on runtime performance.


The other advice about premature optimization and measurement is very good. For some reason embedded systems types (and I'm one) seem to have a hard time taking this to heart.

Cheers,
Phil
Reply all
Reply to author
Forward
0 new messages