views:

87

answers:

1

Hi!

I'm developing a Java EE 6 application where "providers" should be able to define a price and different discounts on a service for users. There are many different providers. Each one provides the same service, the pricing models can be different.

Price Model: - A provider should be able to define the price e.g. per hour, per minute, per process, ... . - The provider should be able to easily add conditions to define the discount a user gets. For example: users from a specific user-group get a discount of 10% and users who used the service more than 5 times get another discount. - It shoulld be able to link conditions with logical operations like "AND" or "OR". - The amount of possible conditions should be defined by the software manufacturer.

  • When a user tries to access the service the user-specific price should be shown. After using the service the particular user gets sometime an invoice where the total cost of this service is listed. While using the service the provider can change the pricing model, so there must be a version number or something. The pricing model versions should then be saved in a database.

The Question is - Is it possible and meaningful to use a rule engine to solve this specification? Provider should define conditions without xml files or something like that, just by clicking and choosing. I have no experience with rule engines... so maybe someone can help me to figure out which solution is best for the problem.

A: 

First of all you need to know all possible variables. You mention the number of times someone has used a service, and group membership. Might be more work than you think if the set of variables can change..

Next up is the level of complexity of the rules that must be supported. You might not need a full-blown rule engine. You can get very far with simple expression evaluations, see https://eval.dev.java.net for example.

If you go for expression evaluation then simply store each pricing model version as its own string in a database or something. You might want point-and-click rules, but often the written counterpart is much clearer.

bitc
The most important thing is to create a flexible pricing model for the provider. All variables that come to my mind are.* Group Membership.* Number of times someone has used the service.* Amount of time a users uses the service per month / year.* Users with specific properties (e.g. all users from xTown).* time the service is used (e.g. from 8.00 PM to 12.00 PM).Its enough when you are able to concatenate rules with the logical operations AND and OR.Maybe Expression Evaluation is not enough.Or is it possible to use Objets in Expressions and persist these expressions?
Michael W.
bitc
Okay i understand, thank you!
Michael W.
I have to think about it... maybe a simple Expression Evaluation is better for the complexity of this Applikation. Rule Engines like Drools however are a interesting option.
Michael W.