Reputation: 1325
I am implementing a lot of complicated business logic that is represented in a truth table/business rules matrix. In the past, implementing these rules has often resulted in a lot of if...else
statements. I can't help but think that a functional language lends itself to expressing these rules more elegantly.
How can I make implementation in Java less painful?
What are some helpful patterns when doing this?
Upvotes: 2
Views: 619
Reputation: 363627
Use a business rules engine instead of writing the rules directly in Java. There exists a standard Java API for these things.
Alternatively, write your rules in a language that supports pattern matching to reduce the number of conditionals. Scala comes to mind.
Upvotes: 4