Basic use of Business Rules

business-rules

I have a query on whether the following requirements would need to be designed via Business Rules – this is for a JEE based application where currently this is coded as part of the Business logic.

System will create a tax account for every city, county and district
combination that imposes tax for only certain cities, counties or
districts depending on the taxpayer's business.

When the user establishes an account which exists in all subdivisions
(i.e. at city or county level), the application must use his tax code
and automatically populate all the locations without requiring the
user to data enter every location.

I assume this would mean a data lookup table from a master table (of tax accounts) and fetch and display all locations. Is there some way in which a Rules Engine can be used to manage these combinations?

Best Answer

You can create your own simple Business Rule Engine with language like Groovy and concept of Domain specific Language (DSL). Business rule written in dynamic language like Groovy (for your J2EE) allow you to change rule/business logic of the application without redeploying. Groovy also have specific features, like metaprogramming, closures, AST transformations, builders that make this task doable. It will be very painful, if not impossible to create decent DSL in java.

Creating domain specific Language (DSL) allow your business users if not code the rule themselves but at least easily read them and understand. And all you need for authoring business rules is simple text editor or Eclipse.

Groovy very well integrated into J2EE application, so you can write only rule portion in the language.

Another question do you really need power and flexibility of business rules and DSL for your application? In my case business want to change rules themselves quite often.

There are resources available if you want to dig deeper: book GroovyInAction Second edition from Manning, book - Groovy for DSL - the later one has a chapter on creating groovy Rule engine - good starting point. There is also several publications online - just goodle for groovy and dsl keywords. http://docs.codehaus.org/display/GROOVY/Writing+Domain-Specific+Languages

Drool is complex piece of software, maybe overkill for task at hand.

Related Topic