dimanche 6 octobre 2019

Need suggestion decide design pattern

Need to what design pattern to use when on the basis of request we have to decide what do with map data. it's basically rest api request.

I was trying to think as a chain of responsibility where i send the map data to each handler and let them decide what to do with data but need to know weather i am correct or not.

like here is my sample code.

if(request.isApplyLimit()){
   //add some data to map or subtract some data to map
}else{
   //substract some data
}

if(request.getDealId() != null){
   //add some data to map or subtract some data to map or some other thing
}else{
  substract some data.
}

if(request.isFetchSlot()){
  // add some data to map or substract or modify data in other way.
}
//some more if else

Aucun commentaire:

Enregistrer un commentaire