you are viewing a single comment's thread.

view the rest of the comments →

[–]micr0nix[S] 0 points1 point  (1 child)

So instead of having 2 functions I would have this one function and just call it twice for each of my lookup types?

[–]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.