I have a question regarding the way of saving the values of some static
data, wich will be used by the drools engine to calculate the price for some
product. I will explain it with the following example:
I have an website where the user can fill a form where he can choose between
different kind of tables, and other specifications regarding to the table.
Lets say we have 3 sort of tables in our store and the user can choose
For each of these types we know, it's a static information wich will not be
calculated on basis of another value, what the price of it is and how long
it will take to produce it. So lets say that we have the following options:
The question is, whats the best way to save the rest of the data ( so the
price and the duration, since the user can only chooses the type) into the
application, so it will be easy to extand the options in the future and it
will be easy to change it by the administrator?
I can think of 3 different ways:
1) Make 3 rules ( in drl ), each for every option and check in the LFS wich
option it's chosen and use the setter for the Price and Duration variabele
of the object Table.
2) Create in the java code 3 different instances of table which will have 3
different values for the variabeles, so instance1 will have Type="90x50",
Price="$50", Duration="7" and instance2 will have the values of
instance3 the values of option3. Then the java application can check what
the user has choosen and insert that into the working memory. So the .drl
file doesn't has set those variabeles of the object, so it can use them in
the rest of the rules.So it doesn't has to know anything about these values.
3) Make a spreadsheet with these 3 differen type tables which will represent
the rules of the value of the Price and Duration on basis of the chosen
Type. So if the application starts, it will compile the spreadsheet so it
can have the latest values for every type of table. So it can use that in
combination with the rest of the rules wich are defined in the .drl file.
These of course with a look in the future extanding of the options, so wich
will be the best practice way to implement. Also its important the the
administrator will be able to easaly change the values of these options.
Will it be easier to add a rule, or will it be easier to add an instance of
the type table on basis of the chosen type in the java code.
If someone has a suggestion about another way of doing these, I will be
glade to hear too!