demystifying the decision model and notation...

37
DEMYSTIFYING THE DECISION MODEL AND NOTATION SPECIFICATION Edson Tirelli Sr Principal Software Engineer Drools Project Lead

Upload: others

Post on 21-May-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

DEMYSTIFYING THE DECISION MODEL AND NOTATION SPECIFICATION

Edson TirelliSr Principal Software EngineerDrools Project Lead

Page 2: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

• DMN: a brief recap • Specification components• What is FEEL

• Conformance Levels: why they matter (and why they don’t)

• The experience implementing a conformance level 3 runtime: challenges of note

Agenda

2

DEMYSTIFYING THE DMN SPECIFICATION

July, 2017

Page 3: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

DECISION MODEL AND NOTATION: A BRIEF RECAP

Page 4: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

4

BRIEF HISTORY

Versions released:

• 1.0 – September 2015• Introduced DMN• Great initial specification, but had a few problems (bugs) that prevented its full implementation.

• 1.1 – June 2016• RTF group worked to fix most of the problems from the version 1.0• It is fully implementable (with a few minor issues)

July, 2017

Page 5: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

5

WHAT IS IN THERE?

The specification defines among other things:

• a graphical language for business decision modelling • a standard notation for decision tables and boxed expressions• an expression language called FEEL (which stands for Friendly Enough Expression Language)• a metamodel and an interchange format (XML)• 3 conformance levels for tool implementations

July, 2017

Page 6: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

6

DMN GRAPHICAL LANGUAGE – EXAMPLE

July, 2017

Imagesource:DMN1.1specification

Page 7: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

7

DMN DECISION TABLES: EXAMPLE

July, 2017

DecisionTablename

Hitpolicy

Rulenumber

Conditions

Resultcolumn

Imagesource:DMN1.1specification

Page 8: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

8

WHAT IS FEEL?

FEEL, which stands for Friendly Enough Expression Language, is a new expression language defined by the DMN specification. It aims to bridge the gap between decision modelling and execution, by assigning semantics to the decision model constructs.

• Aims to be usable by any user “capable of using Excel formulas”• Used in boxed expressions, including Decision Tables• The specification requires the following support for FEEL:

• Conformance Level 2: requires only the features of S-FEEL (a simplified FEEL defined in chapter 9)• Conformance Level 3: requires full implementation of FEEL (as defined in chapter 10)

July, 2017

Page 9: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

9

FEEL EXAMPLE ON A BOXED EXPRESSION

July, 2017

Decisionname

Localvariablenames

DecisionLogic

Inputexpressions

Page 10: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

10

METAMODEL AND INTERCHANGE FORMAT

July, 2017

Page 11: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

CONFORMANCE LEVELS

Page 12: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

12

CONFORMANCE LEVELS

The spec defines 3 incremental conformance levels for implementations:

• Conformance Level 1:• Requires support for authoring of Decision Requirements Diagram, Decision Logic and Decision Tables• This conformance level is basically “documentation only”, no execution required

• Conformance Level 2:• Everything from conformance level 1, plus support for the S-FEEL (simplified FEEL) expression language• Requires execution, and requires the logic modelled in CL1 to be expressed in S-FEEL

• Conformance Level 3:• Everything from conformance level 2, plus support for the full FEEL language• This includes additional modeling elements like: boxed contexts, boxed functions, etc.

July, 2017

Page 13: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

13

CONFORMANCE LEVEL 2

July, 2017

DecisionRequirementsDiagram

Source:BruceSilver’s”Prequalification”example

Page 14: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

14

CONFORMANCE LEVEL 2

July, 2017

BoxedLiteralExpressions DecisionTables

Source:BruceSilver’s”Prequalification”example

Page 15: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

15

CONFORMANCE LEVEL 2

July, 2017

BusinessKnowledgeModel(functiondefinition) FunctionInvocation

Source:BruceSilver’s”Prequalification”example

Page 16: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

16

CONFORMANCE LEVEL 2

What exactly are the limitations of Conformance Level 2?

• S-FEEL is limited to arithmetic expressions and comparisons• no function calls: no data type conversion, no numeric functions, no string manipulation• still supports date/time/duration types as they are considered literals. E.g.: date(“2017-06-18”)

• Only supports the following boxed expressions:• Decision Tables• Boxed Literal Expressions• Boxed Invocation• Business Knowledge Model (function definition)

July, 2017

Page 17: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

WHAT DOES CONFORMANCE LEVEL 3 ADD?

Page 18: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

18

CONFORMANCE LEVEL 3

July, 2017

BoxedContext(torepresentdata)

BoxedContext(todecomposecomplexdecisions)

Source:DMNspecification

Page 19: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

19

CONFORMANCE LEVEL 3

July, 2017

BoxedContext(toimprovereadability)

Source:DMNspecification

Page 20: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

20

CONFORMANCE LEVEL 3

July, 2017

BoxedListsandRelations BoxedFunctionDefinitions

Page 21: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

21

CONFORMANCE LEVEL 3

Full FEEL language syntax and semantics, including:

• Function invocation support: First Name : string before( Full Name, “ ” )Cheapest Price : min( Shopping Cart.Price )

• Logical expressions “if”, “every”, “some”:every Passenger in Passenger List satisfies Passenger.Documents = “verified”if Stock.Price > Order.Stop Loss Price then “hold” else “sell”

• Support for list operations, like mapping values with “for”, filters, etc:Sales Tax : for Product in Shopping Cart return Product.Price * Tax RateNames : Employees[ Department = “Sales” ].Name

July, 2017

Page 22: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

22

CONFORMANCE LEVELS: SUMMARY

Key take-away:

• Conformance level 3 adds a few constructs to the language, but increases language expressiveness to the level required to handle real world decision modelling

• Conformance level 3 defines standard ways of integrating DMN models with external models and tools (Java, PMML)

• Not providing conformance level 3 forces customers/users to use non-standard constructs/integration:• Introduces vendor lock-in, fails to protect customer’s investment• Increases training costs and TCO in general

July, 2017

Page 23: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

CONFORMANCE LEVELS: REALITY

Page 24: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

24

CONFORMANCE LEVELS: REALITY

What is the reality of the DMN tools in the market?

• Many vendors claiming compliance, few go beyond Compliance Level 1• Question: can Microsoft Paint from Windows version 3.0 (from 1990) claim level 1 compliance? J

• Most implementations driven by internal and/or external requirements:• Mix of compliant and non-compliant features• Mix of features that do not match “official” compliance levels (i.e., mix of level 2 and 3 features)• Features that are part of the standard not completely supported (e.g. Decision Tables)

• Vendors only starting to target level 3 (full compliance); Exceptions: Drools/Trisotech and Oracle• CONCLUSION: classification by Compliance Levels (1, 2, 3) is not enough for the current market

July, 2017

Page 25: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

25

CONFORMANCE LEVELS

What conformance level do mine/yours/his product implement?

• OMG does not provide a TCK or reference implementation

• A community driven TCK is being developed by a group of vendors and users, led by Keith Swenson (Fujitsu):• Defines categories (test labels) and

measures compliance for each category• Work in progress, but already publishes

results:https://dmn-tck.github.io/tck/

July, 2017

Page 26: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

SHIFTING GEARS: THE EXPERIENCE OF IMPLEMENTING A LEVEL 3 RUNTIME

Page 27: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

27

SHIFTING GEARS…

Lets change the focus from a user’s perspective, to an implementer's perspective:

• This is about a concrete runtime implementation:• Open source, conformance level 3, runtime implementation• Drools version 7.0.0, Apache v2.0 Licensed• No authoring, seamlessly integrates with Trisotech’s DMN Modeller

• Basked on the joys, felt the pain• Feedback to the RTF for future DMN versions

• I am not currently a member of the RTF group• Submitting tickets for DMN 1.2

July, 2017

Page 28: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

28

THE DMN SPECIFICATION

The good:

• By vendor adoption, the most successful specification so far in the business rules and decision management market• The standard is driving both user’s and vendor’s interest:

• books, training, tools• The specification itself is quite good (kudos to the RTF group):

• defines both syntax and semantics• defines an interchange model• leverages the lessons learned from the BPMN specification• defines an expression language (FEEL)

• RTF members include big names and experienced professionals

July, 2017

Page 29: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

29

THE DMN SPECIFICATION

The bad:

• Version 1.1 still contains a few, important, bugs• A few missing attributes, un-implementable function names, type references as QNames, etc. • Currently solved by “convention” and documentation

• DMN only tackles a small, but important, subset of use cases for business rules: • Decision management• Stateless decision services• BUT, to be fair, would it have succeeded had it tried to tackle more? Others failed before, so I will praise the

decision to stay focused.

July, 2017

Page 30: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

30

THE DMN SPECIFICATION

The ugly:

• Only one: missing FEEL types:• context, list, range, function, unary test

July, 2017

Page 31: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

31

CHALLENGES OF NOTE…

The elephant in the room: spaces in variable names

• DMN supports spaces (and a number of other characters) as part of names (variables, decisions, BKMs, etc)• Makes FEEL grammar context sensitive

• Computer scientists (like myself) cringe when they see it• Vendors claim it is too difficult to implement

• Having implemented it myself I can say:• Users L-O-V-E it! Whom are we building these tools for?• It is not as hard as people think. Don’t believe me? Drools is open source… go look!• The problem is NOT supporting spaces, but limiting spaces

July, 2017

Page 32: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

32

CHALLENGES OF NOTE…

The elephant in the room: spaces in variable names

• The specification says:“A name may contain spaces but may not contain a sequence of 2 or more spaces”

• Logic (decision) results should not depend on the presence or absence of an INVISIBLE character.• On large models, it is hard for users to find errors based on a typo of an invisible character

• First Name should be the same as First Name• There are many invisible characters: white spaces, non-breakable white spaces, line breaks, tabs, etc

• How one differentiates between them if they are invisible?• SOLUTION: ignore all white spaces and normalize all variable names; remove the restriction on the sequence of

spaces.

July, 2017

Page 33: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

33

CHALLENGES OF NOTE…

DMN typerefs: the missing FEEL types

• The FEEL grammar allows expressions to return results of the types:• context. E.g.: { x : 10, y: 8 }• list. E.g.: [ 1, 2, 3 ]• range. E.g.: [“a”..“z”]• function. E.g.: function( x, y ) x+y• unary test. E.g.: < 18

• No way to declare a variable of type range, function or unary test. Declaring a variable of types context or list requires creating an item definition first.

• SOLUTION: add support for these types and document them, even if not part of the current standard

July, 2017

Page 34: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

34

CHALLENGES OF NOTE…

DMN typerefs: defined as QNames in the XML schema

• Some FEEL types contain spaces in their names:• date and time, days and time duration, years and months duration

• XML QNames do not allow spaces• DMN schema defines typerefs as QNames• SOLUTION: until DMN 1.2 fixes this issue:

• Create, document, and support synonyms for these types: dateTime, dayTimeDuration, yearMonthDuration• Aligned with Trisotech and Bruce Silver’s Method & Style

• Ignore schema rules and process QName as a string, supporting spaces. E.g.:• <variable name=“Birth Date” typeref=“feel:date and time”/>

July, 2017

Page 35: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

35

CHALLENGES OF NOTE…

Some chapters/paragraphs of the DMN specification are a bit hard to understand

• A few contradictions in some places, a few ambiguities inherent to the English language in others, a lot of content to learn

• DMN success relies on the fact that it defines not only syntax, but semantics• SOLUTION: engage with the community and subject matter experts

• Huge thank you to Bruce Silver, always accessible and open to discussions• + wrote a great book, much easier to read than the spec• + created the initial TCK tests

• Huge thank you to Trisotech (Denis Gagné, Mélanie Gauthier, Simon Ringuete)• Thank you to the DMCommunity forum (including Gary Hallmark)

July, 2017

Page 36: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

36

Q&A

Where to get more information:

• DMN specification: http://www.omg.org/spec/DMN/• Drools Website: http://drools.org/• Drools IRC: http://drools.org/community/chat.html• Bruce Silver’s book: DMN Method & Style : http://methodandstyle.com/books/

July, 2017

Page 37: DEMYSTIFYING THE DECISION MODEL AND NOTATION …2017.ruleml-rr.org/wp-content/uploads/...DMN_draft.pdfDMN specification. It aims to bridge the gap between decision modelling and execution,

plus.google.com/+RedHat

linkedin.com/company/red-hat

youtube.com/user/RedHatVideos

facebook.com/redhatinc

twitter.com/RedHatNews

THANK YOU