Answer the question
In order to leave comments, you need to log in
Who puts the business rules in the database?
I have a task to create an interface for creating and editing business rules with their subsequent extraction and execution. Rules can be of varying complexity
For example:
1. If the order has the number of positions = 2 THEN The price is lower by 10 rubles
but also more complex
2. if the order contains (number_of_positions = 2 and dispatch_city = "Moscow") or (City = "St. Petersburg" ") THEN delivery is carried out by the company "Horns and Kopta"
The fields by which the comparison can be dynamic, there can be many rules for one order
Answer the question
In order to leave comments, you need to log in
A decision table (decision table) is a very efficient solution for this kind of problem.
From Russian Wikipedia:
In English - Decision table - you can find much more useful material than in Russian. Let's say this is an explanation video .
Tables can be stored in the DBMS and exchanged using CSV.
IBM and many other companies use them in various of their products. Especially useful for describing the activities of accounting, warehouse accounting, etc.
The business logic in base is such to itself. Logic can change, become more complex, become dynamic. If possible, the application should not know about the database.
We are talking about a similar problem "Are you going to write your own interpreter for another programmer using an interpreter written for you?"
Even if you write your own convenient language, then only you will program in it. And there will be a dozen different kinds of rules encoded on it, because business really doesn’t need a lot. It is we programmers who are trying to embrace the unimaginable, and business works according to clear and simple rules. )
I suggest you write five classes that, with a bunch of switches and checkboxes, implement the same dozen business rule skeletons. Simple, reliable, beautiful.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question