这里是代码...我的if,else语句很长...如何区分它?任何建议?谢谢。如何使此代码更好地组织
public function receiveMsg(aMsg){
if($aMsg instanceof LoginMsg){
$this->callingSomeMethod(); //should I separate this code into other class/ object?
$this->callingAnotherMethod(); //should I separate this code into other class/ object?
$aMsg = new RespondLoginMsg(); //should I separate this code into other class/ object?
$this->sendMsg($aMsg); //should I separate this code into other class/ object?
}else if(aMsg instanceof LogoutMsg){
$this->callingSomeMethod(); //should I separate this code into another class/ object?
$aMsg = new RespondLogoutMsg(); //should I separate this code into another class/ object?
$this->sendMsg($aMsg); //should I separate this code into another class/ object?
}else if/*****bababab***/
/*****many else if here (up to 200 msg+ , just upload 2 here.)***/
}
不,你可以看到,第二个是RespondLogoutMsg而不是RespondLoginMsg ..... – Tattat
啊哈。错过了,对不起。 – craigmc