I've been repeatedly told not repeat myself when programming. I've come across a scenario where I'm wondering whether to write two functions, each for a particular purpose, or a single function that handles both purposes. I'm not sure what is the "best practices" approach:
All functions in question deal with allowing a person to change the rank of a list item by one position, plus or minus one. All items and their ranks are saved in a MySQL database table.)
Two functions One function to move an item's rank up by one, and another to move the rank down by one.
One function I can write the same functions into one by adding an additional argument of "direction" and using an if statement to decide whether to move an item up, or down.
In terms of performance, is it better to write two functions and let them share the load? Is there such a thing as "function overload" if the same function is receiving a ton of requests?
I don't think it is relevant, but I'm using ColdFusion, and my additional "direction" argument would be a string wrapped in a statement that checks it's value to determine which action to take.