Voici le code ... Mon if, else statement est très long ... Comment le séparer? Toute suggestion? Je vous remercie.Comment mieux organiser ce code
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.)***/
}
pas, comme vous pouvez le voir, le second est RespondLogoutMsg au lieu de RespondLoginMsg ..... – Tattat
Aha. Manqué ça, désolé. – craigmc