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:
- If value of origin = mobile
following request parameters are mendatory: location, mobile number, customer id
following request parameters are optional: ipaddress, email address
- 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