I need to have two functions which one is the alias of the other one because of backward compatibility issue.
public function getMostPopularArticles(array $params = array())
{
$this->getMostViewedArticles($params);
}
public function getMostViewedArticles(array $params = array())
{
return $this->_response_request(".....");
}
getMostPopularArticles() is the new function that is the alias to the older function (which in time will be removed) getMostViewedArticles()
Am, I doing it the right way? Any room for improvements?
I have to mention that getMostViewedArticles() (the old function) is using the new parameters to return the right data, but I just have to an alias with the correct name (getMostPopularArticles()) so users have the time needed to update their code and in a future release, remove completely the old named function.
Why don’t you do :
This way, any new changes will only need to be done in
getMostPopularArticlesbutgetMostViewedArticlescan be still used by legacy code.Also
getMostPopularArticlesshould have whatever business logic you are currently using, since that is the newer function which you want to continue using