This is a very generic 'best practice' question, but here's an example.
Let's say I have a movie cataloging app. I want to give my users the chance to specify, say, IMDb or Metacritic for their synopsis/ rating info.
Do I do this:
if (preferredSupplier == "imdb"){
getIMDbRating(movieName);
}else{
getMetacriticRating(movieName);
}
Or this:
getRating(movieName, preferredSupplier);
I like the second one better, but it means that function will have to follow vastly different logic depending on the value of the second parameter (for example Metacritic might require a screen scrape, where IMDb might have a nice API).
Or should I combine them? As in getRating() acts as a wrapper function, and calls getIMDbRating() or getMetacriticRating() depending on the value of the second param.