-4

I faced a task when I need to process a bunch of conditions and perform an action in the result. Are there any libraries or approaches that can help me building a structure like this? With replaceable/amendable conditions and results?

Eduard
  • 516
  • 1
  • 4
  • 17

1 Answers1

1

There are several patterns here, you can use Chain Of Responsibility to extract out the logic into separate classes.

If you want to fully extract it, there are rules engines that can help with that, making the if/else more data-driven. This has it's own concerns, namely around testing, promotion, etc...

Feel free to peruse my rant against rules engines: Method or pattern to implement a Business Rules Engine in a solution?

Rob Conklin
  • 8,806
  • 1
  • 19
  • 23