lundi 6 février 2017

Java design pattern for varied behaviour for different request paramete

In my Java/Spring application, I have several several services implementations. If I take example of one service, which validates the request parameters. Core behaviour of this service is dynamic and dependent on few of the request parameters. Here are few cases:

  1. If value of origin = mobile

following request parameters are mendatory: location, mobile number, customer id

following request parameters are optional: ipaddress, email address

  1. If value of origin = web

following request parameters are mendatory: ipaddress, email address, customer id

following request parameters are optional: location, mobile number

Currently, we have build this service method using if and else blocks, which doesn't look good and even increasing the complexity and making it complex to maintain and understand.

Aucun commentaire:

Enregistrer un commentaire