samedi 14 mai 2022

Which design pattern is useful to evaluate conditions and return Boolean value

I would like to know best coding practice or design pattern which I can follow to achieve following task in Java: I need to enable check box in UI based on certain criteria/condition to check if those are satisfied in business layer which is written in Java.

There are 3 conditions which I need to evaluate, but I don't want to write if-else block inside single method to determine it. Also one or two condition will be common which will be used at other place too.

As of now, I am thinking to create one abstract class and create various implemention of it for conditions. Then create a list of those conditions class and evaluate in for loop one by one. Is that correct approach?

Aucun commentaire:

Enregistrer un commentaire