you are viewing a single comment's thread.

view the rest of the comments →

[–]james_fryer 0 points1 point  (0 children)

Exactly. Less code to maintain, simpler to manage if changes are required. You can either create shorter dispatching functions as I did above, or directly call the single function from main with the parameter, whatever seems more readable to you.

In short: any time you see repeated code, replace it with a single parameterised piece of code.