花痴流口水颜文字
Drools is extensively used in the BFSI Industry(Banking, Financial services and Insurance). The primary reason being the continuously changing requirements and the addition of new rules which keeps on adding given the Volatility in the BFSI Industry.
Drools在BFSI行业 (银行,金融服务和保险)中得到广泛使用。 主要原因是不断变化的要求以及在BFSI行业波动的情况下不断增加的新规则。
Let us take an example of a system where trades are coming from external system in the form of XML
and JAXB
is used and casted into customized Java Object
. Now there are business rules which needs to be applied on certain parameters in the xml.
让我们以一个系统的示例为例,其中交易来自XML
形式的外部系统,并且使用JAXB
并将其转换为自定义Java Object
。 现在,有一些业务规则需要应用于xml中的某些参数。
So the code would be something like:
因此,代码将类似于:
if (trade.getProductInformation() == Product.IRS) {
// do something for IRS (Interest Rate Swap Trade)
}
else if (trade.getProductInformation() == Product.CDS) {
if (trade.getPartyIds() == null) {
// do something else for CDS trades with no Party Id
}
else {
if(trade.getTradeId() ! =null) {
//do something
}
}
}
Now currrent java code handles two product type (IRS and CDS) and the application wants to onboard a third product(Bonds), the above Java code will be very difficult to maintain and change every time a new condition has to be introduced.
现在,当前的Java代码处理两种产品类型( IRS和CDS ),并且应用程序希望使用第三种产品(债券) ,每次必须引入新条件时,上述Java代码将很难维护和更改。
The solution to the rescue is using a Rule Engine
. With Rule Engine your business logic is segregated in Rules and if there is a new product to be on boarded, only new rules would have to be added.
救援的解决方案是使用Rule Engine
。 使用Rule Engine,您的业务逻辑将被隔离在Rule中,并且如果要使用新产品,则只需添加新规则。
For example:
例如:
if Trade( productInformation == Product.IRS)
then do something else for IRS Trade
if Trade( productInformation == Product.CDS)
then do something for CDS trade
Now a new system is added so a new rule would be:
现在添加了一个新系统,因此新规则将是:
if Trade( productInformation == Product.BONDS)
then do something for BONDS trade
The above example is a simple one (just for reference). When there are a lot of nested if
and else
statements in the code then using rules really help in easily adding new requirements/changes to the application and also the modification of the existing rules.
上面的示例是一个简单的示例(仅供参考) 。 当代码中有很多嵌套的if
和else
语句时,使用规则确实有助于轻松地向应用程序中添加新的需求/更改以及对现有规则的修改。
翻译自: https://www.studytonight.com/drools/problem-trad-approach
花痴流口水颜文字