for example, the code for the first version is:
//api
public function buyGoods(){
//
$validate->validateParam();
//
$goods->buy();
}
at this time, the first version is running steadily, and we hope that we will not modify this member method too much, but the requirement of the second version is to add some handling functions after the function has been processed. For example, the code of the second version is:
//api
public function buyGoods(){
//
$validate->validateParam();
//
$goods->buy();
//
$user->credit();
//
$user->money();
...n
}
this credit () and money () are added later, and if you want to add these functions, you must modify buyGoods (), which destroys the original buyGoods ().
is there a design pattern that allows member methods to be easily extended without changing the original code?