Quantcast
Channel: User Filip Milovanović - Software Engineering Stack Exchange
Viewing all articles
Browse latest Browse all 167

Comment by Filip Milovanović on How to combine multiple functions into a single template based function

$
0
0
"One can see that the two functions are almost similar" - Kent Beck's refactoring mantra is "Make the change easy (this might be hard), then make the easy change". So the first step is to make the two functions look the same, and the rest is the "easy change" part. If you have an entire block of code that varies between the two (and not having one is a variant), than make that block of code a parameter (a lambda or an object). Such a block of code can itself take parameters and return a value, so you'll need to come up with a general enough signature. 1/2

Viewing all articles
Browse latest Browse all 167

Trending Articles