Switch State vs DP

A Client/Server application uses switch statement to handle incoming messages from server to client and vice versa. I want to hide application logic in the switch statement to a design pattern. Which pattern could be used to handle messages in this code, is Stragety pattern would be a good one ?


switch ((CTSMessage)id)
{
case CTSMessage.Connect:
this.connectProc(cNode, buffer);
break;
case CTSMessage.SearchEngine:
this.searchEngineProc(cNode, buffer);
break;
case CTSMessage.PeerListRequest:
this.peerListRequestProc(cNode);
break;
case CTSMessage.ChatMesssage:
this.chatMessageProc(buffer);
break;
}

Comments

  • edited November -1
    yes, strategy pattern seems to be the right solution