mercredi 13 mai 2015

is there any design pattern available for this ? or Whats the better the way to structure the code [duplicate]

This question already has an answer here:

In this below code , there will be many if and else block in onMediaStateChange() based on the call status, is there any better to write ?

Following is the code, and i want to structure the code as per the java standards.Is there any pattern to follow here or any better to write this code ?

void onMediaStateChange(Call call){
//call hold response

// unhold response

}

void onCallStateChange(Call call){

//incoming call
//call answered
//call end
}

void makeCall(){
  // initiates call, listeners are set
}
void hold_call(Call call){
 //holds the call.
 //this is asynchronous call.Response will appear in callback method.
}

void unhold_call(){
//unholds the call
//this is asynchronous call.Response will appear in callback method.
}

void call_transfer(){
      //should hold active call if any.
//wait for hold response and 
// transfer the call.

}

void someMethod1(){
 //should hold active call if any.
//wait for hold response and 
// take some action
}


void someMethod2(){
 //should hold active call if any.
//wait for hold response and 
// take some action
}

Aucun commentaire:

Enregistrer un commentaire