Reputation: 7688
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.
Upvotes: 0
Views: 44
Reputation: 12826
Why don't you do :
public function getMostViewedArticles(array $params = array())
{
return getMostPopularArticles($params);
}
This way, any new changes will only need to be done in getMostPopularArticles
but getMostViewedArticles
can be still used by legacy code.
Also getMostPopularArticles
should have whatever business logic you are currently using, since that is the newer function which you want to continue using
public function getMostPopularArticles(array $params = array())
{
return $this->_response_request(".....");
}
Upvotes: 2
Reputation: 11467
If you have a deprecated function, you should essentially eschew it in all new code. When the function is deleted, your code will (obviously) break. Therefore, you should not call the deprecated function: you should instead copy and paste the code (or rewrite it) in the new call.
Upvotes: 0