pkananen
pkananen

Reputation: 1325

What is the best way to represent a complicated truth table in Java or other OO/non-functional languages?

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

Answers (1)

Fred Foo
Fred Foo

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

Related Questions