We have covered some of the most used components in a knowledge base, such as rules, globals, queries, and channels. It is time to move on to more advanced topics that will allow us to create more concise and reusable knowledge.
In this section, we are going to cover topics such as functions, custom operators, and custom accumulate functions. All these components can be used to model our knowledge in a simpler yet powerful way.
So far, we have covered three of the most common knowledge declarations that we have in Drools: rules, queries, and declared types. There is another kind of knowledge declaration that can be used to express stateless logic in a knowledge base: functions. Functions in Drools are basically isolated pieces of code that will optionally take arguments and may or may not return a value. Functions are useful for situations where we want to define some logic in a knowledge base instead of having it, for example, in an external Java class.
The syntax...