SlideShare uma empresa Scribd logo
1 de 65
Baixar para ler offline
Obey the Rules! ,[object Object],[object Object],[object Object]
What is a rules engine?
Rules engines  ,[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],Business rules Business process : keep stores well stocked. Business rule : If the number of shirts in a store gets below 15, order more.
[object Object],[object Object],[object Object],[object Object],Keep ‘em Separated
 
Why use a rules engine in your application? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
How are rules defined and implemented?
Typical workflow from business to technology The organization defines the business processes.
Typical workflow from business to technology A business analyst translates business practices into business rule statements, constraints and actions.
Typical workflow from business to technology The software developer implements the rules engine component in the application. The actions and triggers are implemented by the developer. The application is deployed by a developer with the rules externalized
Typical workflow from business to technology The organization changes some business processes.
Typical workflow from business to technology If the business process doesn’t require new actions, anyone, including this silly intern with a small desk, can update the rules engine.  Win.
Why use a  client-side  rules engine in your Flex RIA? ,[object Object],[object Object],[object Object],[object Object]
How do rules engines work?
Rules Engine Anatomy ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Rules Engine Anatomy: t-shirt inventory Facts Rules Conditions Actions ,[object Object],[object Object],[object Object]
Rules Engine Anatomy: clown alarm system Facts Rules Conditions Actions ,[object Object],[object Object],[object Object],[object Object],[object Object],http://www.axecop.com
Examples!
Real world use case 1 FormBuilderUI:  AS3 rules engine under the hood AS3 rules engine under the hood ,[object Object],[object Object],[object Object]
 
 
The Stack...
The Rules... < rule  id = &quot;isFemale&quot; > < statement ><![CDATA[  @info.sex equalTo 'Female'  ]]></ statement > < actions > < visibleAction  questionIDs = &quot;areYouPregnant&quot; /> </ actions > </ rule > < rule  id = &quot;isTeenager&quot; > < statement ><![CDATA[ @info.age greaterThanOrEqualTo '13' AND  @info.age lessThan '18'  ]]></ statement > < actions > </ actions > </ rule > < rule  id = &quot;isTeenageGirl&quot; > < statement ><![CDATA[ $isTeenager AND $isFemale  ]]></ statement > < actions > < urlAction  url = &quot; http://www.seventeen.com &quot;  /> </ actions > </ rule >
Regular Expressions public   static   var  andOrTrueFalsePattern:RegExp =  /AND|OR|true|false/ gi; public   static   var  ruleTokenPattern:RegExp =  /([a-zA-Z0-9_]+)/ g; public   static   var  propertyTokenPattern:RegExp =  /([a-zA-Z0-9_.]+)/ g; public   static   var  nonSpaceGroups:RegExp =  /([a-zA-Z0-9_.'&quot;]+)([^ ])/ gi; public   static   var  quotesPattern:RegExp =  /'|&quot;/ gi;
Pattern matching a rule...
Boolean parsing using short circuit ,[object Object],var  matches:Array = [ true ,  &quot;AND&quot; ,  false ,  &quot;AND&quot; ,  true ,  &quot;OR&quot;   true ]; var  operator:String;  var  nextValue:Boolean; var  overallValue:Boolean = matches[0]; var i:int = 1; while  (i < matches.length - 1) { operator=matches[i]; nextValue=StringUtil.stringToBoolean(matches[i + 1]); if  (isAndOperator(operator)) { overallValue=(overallValue && nextValue); if  (overallValue ==  false ) return   false ; }  else   if  (isOrOperator(operator)) { overallValue=(overallValue || nextValue); if  (overallValue ==  true ) return   true ; } i = i + 2; }
Hamcrest API - Matchers: public   static   const  EQUAL_TO:String =  &quot;equalTo&quot; ; public   static   const  NOT_EQUAL_TO:String =  &quot;notEqualTo&quot; ; public   static   const  LESS_THAN:String =  &quot;lessThan&quot; ; public   static   const  LESS_THAN_OR_EQUAL_TO:String =  &quot;lessThanOrEqualTo&quot; ; public   static   const  GREATER_THAN:String =  &quot;greaterThan&quot; ; public   static   const  GREATER_THAN_OR_EQUAL_TO:String =  &quot;greaterThanOrEqualTo&quot; ; public   static   const  CONTAINS:String =  &quot;contains&quot; ;
Hamcrest API:  Get your facts straight! public   static   function  evaluateCondition(target:*, operator:String, source:*):Boolean { try  { switch  (operator) { case  Matchers.EQUAL_TO: assertThat(target, equalTo(source)); break ; case  Matchers.NOT_EQUAL_TO: assertThat(target, not(equalTo(source))); break ; case  Matchers.LESS_THAN: assertThat(Number(target), lessThan(Number(source))); break ; default : throw   new  RuleError( &quot;No matcher found for this operator!” ); } }  catch  (e:Error) { if  (e.errorID != RuleError.ILLEGAL_OPERATOR_ERROR) { value= false ; }  else  { _logger.error(e.message, e.errorID); } }
Type of Rules engines ,[object Object]
[object Object],[object Object],[object Object],[object Object],Engine types:  production(inference)
Engine types:  reactive ,[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],Rule Processing Algorithms
Basic Algorithm ,[object Object],[object Object],[object Object],[object Object]
Basic Algorithm Fact condition A Action Fact cB cC cD AND OR Fact Optimizations can give priority to certain conditions, wait to process until all facts are run through conditions, etc.
Rete Algorithm ,[object Object],[object Object],[object Object],[object Object]
Rete Algorithm ,[object Object],[object Object],[object Object],[object Object]
Rete Algorithm ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Rete Algorithm Fact1 condition A Action Fact3 cB cC cD AND OR ,[object Object],[object Object],[object Object],[object Object],[object Object],Fact2
Real world use case 2: Herff Jones Order Manager Herff Jones Order Manager ,[object Object],[object Object],[object Object]
 
 
Technical Challenges ,[object Object],[object Object],[object Object],[object Object],[object Object]
Core Components ,[object Object],[object Object],[object Object],[object Object]
Core UI ,[object Object],[object Object],[object Object],[object Object],[object Object]
Rule XML Sample <!-- Rule definition --> < rule > < getValue  key = &quot;Metal Quality&quot; >< containsString  value = &quot;Gold&quot; /></ getValue > < addValueOption  key = &quot;Metal Finish&quot;  value = &quot;Gold-on-Gold&quot;  meta = &quot;code:2&quot; /> </ rule >
Macro XML Sample: pricing a stone <!-- Macro definition --> < defineMacro  name = &quot;priceStone&quot; > < rule > < allOf > < getValue  key = &quot;$stoneKey&quot; >< equalTo  value = &quot;$stoneValue&quot; /></ getValue > < getValue  key = &quot;$stoneSizeKey&quot; >< equalTo  value = &quot;$stoneSizeValue&quot; /></ getValue > </ allOf > < addPrice  label = &quot;$stoneKey: $stoneValue&quot;  amount = &quot;$amount&quot; /> </ rule > </ defineMacro > <!-- Macro implementation --> < priceStone  stoneKey = &quot;Royal Stone&quot;  stoneValue = &quot;Birthstones - Alexandrite (Jun)&quot;  stoneSizeKey = &quot;Royal Stone Size&quot;  stoneSizeValue = &quot;12 Point&quot;  amount = &quot;4208&quot; />
Real world use case 3: A Statewide Agency  Government Benefits Application (GBA) Government Benefits Application (GBA) Government Benefits Application (GBA) ,[object Object],[object Object],[object Object]
GBA Overview Overview ,[object Object]
Functionality ,[object Object],[object Object],[object Object]
Technical Challenges ,[object Object],[object Object],[object Object]
Core Components ,[object Object],[object Object],[object Object]
...Core Components ,[object Object],[object Object],[object Object]
GBA Rules engine architecture Fact (change event) Conditions Actions User Questions Data Model Binding! Binding! Binding!
Core UI ,[object Object],[object Object],[object Object],[object Object]
Question XML < question  id = &quot;362&quot; controlType = &quot;ComboBox&quot; inlineHelp = &quot;Does anyone receive money from elsewhere?&quot; label = &quot;Other Employment&quot; optionsID = &quot;R00013&quot; target = &quot;Household.Income.OtherIncome&quot; />
Condition XML ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Rule XML < rule  id = &quot;doesAnyoneHasOtherEmployment&quot; > < statement > $hasOtherEmployment </ statement > < actions > < visibleAction  questionGroupIDs = &quot;income_other&quot; /> </ actions > </ rule > < rule  id = &quot;NoEmployment&quot; > < statement > $IsOnStrike OR ($NoFutureEmployment AND $NoCurrentEmployment AND $NoPastEmployment AND $NoOtherIncome) </ statement > < actions > < visibleAction  questionIDs = &quot;364&quot; /> </ actions > </ rule >
Data Abstraction
Dynamic Binding using ObjectProxy ,[object Object],[object Object],[object Object],[object Object],[object Object]
What next? ,[object Object],[object Object]
Forward Chaining (modus ponens) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Forward Chaining ,[object Object],[object Object],[object Object],[object Object],[object Object]
Forward Chaining:  definition ,[object Object],[object Object],[object Object],[object Object],[object Object]
Thanks for obeying. Drew McLean twitter:  TunnelVisionary [email_address] RJ Owen twitter: rjowen [email_address]

Mais conteúdo relacionado

Destaque

Developing a Real-time Engine with Akka, Cassandra, and Spray
Developing a Real-time Engine with Akka, Cassandra, and SprayDeveloping a Real-time Engine with Akka, Cassandra, and Spray
Developing a Real-time Engine with Akka, Cassandra, and SprayJacob Park
 
Rule Engine & Drools
Rule Engine & DroolsRule Engine & Drools
Rule Engine & DroolsSandip Jadhav
 
Programming the Physical World with Device Shadows and Rules Engine
Programming the Physical World with Device Shadows and Rules EngineProgramming the Physical World with Device Shadows and Rules Engine
Programming the Physical World with Device Shadows and Rules EngineAmazon Web Services
 
Them's the Rules - Using a Rules Engine to Wrangle Complexity
Them's the Rules - Using a Rules Engine to Wrangle ComplexityThem's the Rules - Using a Rules Engine to Wrangle Complexity
Them's the Rules - Using a Rules Engine to Wrangle ComplexityMicah Breedlove
 

Destaque (6)

Best practices webinar
Best practices webinarBest practices webinar
Best practices webinar
 
Developing a Real-time Engine with Akka, Cassandra, and Spray
Developing a Real-time Engine with Akka, Cassandra, and SprayDeveloping a Real-time Engine with Akka, Cassandra, and Spray
Developing a Real-time Engine with Akka, Cassandra, and Spray
 
Drools
DroolsDrools
Drools
 
Rule Engine & Drools
Rule Engine & DroolsRule Engine & Drools
Rule Engine & Drools
 
Programming the Physical World with Device Shadows and Rules Engine
Programming the Physical World with Device Shadows and Rules EngineProgramming the Physical World with Device Shadows and Rules Engine
Programming the Physical World with Device Shadows and Rules Engine
 
Them's the Rules - Using a Rules Engine to Wrangle Complexity
Them's the Rules - Using a Rules Engine to Wrangle ComplexityThem's the Rules - Using a Rules Engine to Wrangle Complexity
Them's the Rules - Using a Rules Engine to Wrangle Complexity
 

Semelhante a Obey The Rules: Implementing a Rules Engine in Flex

Droolsand Rule Based Systems 2008 Srping
Droolsand Rule Based Systems 2008 SrpingDroolsand Rule Based Systems 2008 Srping
Droolsand Rule Based Systems 2008 SrpingSrinath Perera
 
Aug Xml Net Forum Dynamics Integration
Aug Xml Net Forum Dynamics IntegrationAug Xml Net Forum Dynamics Integration
Aug Xml Net Forum Dynamics IntegrationMariAnne Woehrle
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalystdwm042
 
Rules Programming tutorial
Rules Programming tutorialRules Programming tutorial
Rules Programming tutorialSrinath Perera
 
Biz Talk Demo slideshare
Biz Talk Demo slideshareBiz Talk Demo slideshare
Biz Talk Demo slideshareerios
 
Design Summit - Advanced policy state management - John Hardy
Design Summit - Advanced policy state management - John HardyDesign Summit - Advanced policy state management - John Hardy
Design Summit - Advanced policy state management - John HardyManageIQ
 
Puppeting in a Highly Regulated Industry
Puppeting in a Highly Regulated IndustryPuppeting in a Highly Regulated Industry
Puppeting in a Highly Regulated IndustryPuppet
 
Spring Transaction
Spring TransactionSpring Transaction
Spring Transactionpatinijava
 
Sap grc process control 10.0
Sap grc process control 10.0Sap grc process control 10.0
Sap grc process control 10.0Latha Kamal
 
Business Process Execution Language
Business Process Execution LanguageBusiness Process Execution Language
Business Process Execution Language招政 蔣
 
Oracle Sql Tuning
Oracle Sql TuningOracle Sql Tuning
Oracle Sql TuningChris Adkin
 
Michiel Overeem (AFAS) - Enterprise software schaalbaar maken met Service Fab...
Michiel Overeem (AFAS) - Enterprise software schaalbaar maken met Service Fab...Michiel Overeem (AFAS) - Enterprise software schaalbaar maken met Service Fab...
Michiel Overeem (AFAS) - Enterprise software schaalbaar maken met Service Fab...AFAS Software
 
ABPerformance Quick Tour
ABPerformance Quick TourABPerformance Quick Tour
ABPerformance Quick TourActive Base
 
Priority Quick Tour
Priority Quick TourPriority Quick Tour
Priority Quick TourActive Base
 
Observability foundations in dynamically evolving architectures
Observability foundations in dynamically evolving architecturesObservability foundations in dynamically evolving architectures
Observability foundations in dynamically evolving architecturesBoyan Dimitrov
 
ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introductionTomi Juhola
 
Intelligent Supermarket using Apriori
Intelligent Supermarket using AprioriIntelligent Supermarket using Apriori
Intelligent Supermarket using AprioriIRJET Journal
 
Java Script Isn\'t a Toy Anymore
Java Script Isn\'t a Toy AnymoreJava Script Isn\'t a Toy Anymore
Java Script Isn\'t a Toy AnymoreAlexis Williams
 
Drools Presentation for Tallink.ee
Drools Presentation for Tallink.eeDrools Presentation for Tallink.ee
Drools Presentation for Tallink.eeAnton Arhipov
 

Semelhante a Obey The Rules: Implementing a Rules Engine in Flex (20)

Droolsand Rule Based Systems 2008 Srping
Droolsand Rule Based Systems 2008 SrpingDroolsand Rule Based Systems 2008 Srping
Droolsand Rule Based Systems 2008 Srping
 
Aug Xml Net Forum Dynamics Integration
Aug Xml Net Forum Dynamics IntegrationAug Xml Net Forum Dynamics Integration
Aug Xml Net Forum Dynamics Integration
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 
Rules Programming tutorial
Rules Programming tutorialRules Programming tutorial
Rules Programming tutorial
 
Biz Talk Demo slideshare
Biz Talk Demo slideshareBiz Talk Demo slideshare
Biz Talk Demo slideshare
 
Design Summit - Advanced policy state management - John Hardy
Design Summit - Advanced policy state management - John HardyDesign Summit - Advanced policy state management - John Hardy
Design Summit - Advanced policy state management - John Hardy
 
Puppeting in a Highly Regulated Industry
Puppeting in a Highly Regulated IndustryPuppeting in a Highly Regulated Industry
Puppeting in a Highly Regulated Industry
 
Spring Transaction
Spring TransactionSpring Transaction
Spring Transaction
 
Sap grc process control 10.0
Sap grc process control 10.0Sap grc process control 10.0
Sap grc process control 10.0
 
Boston 16 03
Boston 16 03Boston 16 03
Boston 16 03
 
Business Process Execution Language
Business Process Execution LanguageBusiness Process Execution Language
Business Process Execution Language
 
Oracle Sql Tuning
Oracle Sql TuningOracle Sql Tuning
Oracle Sql Tuning
 
Michiel Overeem (AFAS) - Enterprise software schaalbaar maken met Service Fab...
Michiel Overeem (AFAS) - Enterprise software schaalbaar maken met Service Fab...Michiel Overeem (AFAS) - Enterprise software schaalbaar maken met Service Fab...
Michiel Overeem (AFAS) - Enterprise software schaalbaar maken met Service Fab...
 
ABPerformance Quick Tour
ABPerformance Quick TourABPerformance Quick Tour
ABPerformance Quick Tour
 
Priority Quick Tour
Priority Quick TourPriority Quick Tour
Priority Quick Tour
 
Observability foundations in dynamically evolving architectures
Observability foundations in dynamically evolving architecturesObservability foundations in dynamically evolving architectures
Observability foundations in dynamically evolving architectures
 
ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introduction
 
Intelligent Supermarket using Apriori
Intelligent Supermarket using AprioriIntelligent Supermarket using Apriori
Intelligent Supermarket using Apriori
 
Java Script Isn\'t a Toy Anymore
Java Script Isn\'t a Toy AnymoreJava Script Isn\'t a Toy Anymore
Java Script Isn\'t a Toy Anymore
 
Drools Presentation for Tallink.ee
Drools Presentation for Tallink.eeDrools Presentation for Tallink.ee
Drools Presentation for Tallink.ee
 

Mais de RJ Owen

Moral Design (Denver Startup Week)
Moral Design (Denver Startup Week)Moral Design (Denver Startup Week)
Moral Design (Denver Startup Week)RJ Owen
 
Moral designfinal
Moral designfinalMoral designfinal
Moral designfinalRJ Owen
 
Flex4 component lifecycle
Flex4 component lifecycleFlex4 component lifecycle
Flex4 component lifecycleRJ Owen
 
Flex 4 Overview
Flex 4 OverviewFlex 4 Overview
Flex 4 OverviewRJ Owen
 
Adobe Flex 3 Component Life Cycle
Adobe Flex 3 Component Life CycleAdobe Flex 3 Component Life Cycle
Adobe Flex 3 Component Life CycleRJ Owen
 
Flex3 Deep Dive Final
Flex3 Deep Dive FinalFlex3 Deep Dive Final
Flex3 Deep Dive FinalRJ Owen
 
Adobe Flex Component Lifecycle
Adobe Flex Component LifecycleAdobe Flex Component Lifecycle
Adobe Flex Component LifecycleRJ Owen
 

Mais de RJ Owen (7)

Moral Design (Denver Startup Week)
Moral Design (Denver Startup Week)Moral Design (Denver Startup Week)
Moral Design (Denver Startup Week)
 
Moral designfinal
Moral designfinalMoral designfinal
Moral designfinal
 
Flex4 component lifecycle
Flex4 component lifecycleFlex4 component lifecycle
Flex4 component lifecycle
 
Flex 4 Overview
Flex 4 OverviewFlex 4 Overview
Flex 4 Overview
 
Adobe Flex 3 Component Life Cycle
Adobe Flex 3 Component Life CycleAdobe Flex 3 Component Life Cycle
Adobe Flex 3 Component Life Cycle
 
Flex3 Deep Dive Final
Flex3 Deep Dive FinalFlex3 Deep Dive Final
Flex3 Deep Dive Final
 
Adobe Flex Component Lifecycle
Adobe Flex Component LifecycleAdobe Flex Component Lifecycle
Adobe Flex Component Lifecycle
 

Último

Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Jeffrey Haguewood
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentMahmoud Rabie
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...itnewsafrica
 

Último (20)

Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career Development
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
Irene Moetsana-Moeng: Stakeholders in Cybersecurity: Collaborative Defence fo...
 

Obey The Rules: Implementing a Rules Engine in Flex

  • 1.
  • 2. What is a rules engine?
  • 3.
  • 4.
  • 5.
  • 6.  
  • 7.
  • 8. How are rules defined and implemented?
  • 9. Typical workflow from business to technology The organization defines the business processes.
  • 10. Typical workflow from business to technology A business analyst translates business practices into business rule statements, constraints and actions.
  • 11. Typical workflow from business to technology The software developer implements the rules engine component in the application. The actions and triggers are implemented by the developer. The application is deployed by a developer with the rules externalized
  • 12. Typical workflow from business to technology The organization changes some business processes.
  • 13. Typical workflow from business to technology If the business process doesn’t require new actions, anyone, including this silly intern with a small desk, can update the rules engine. Win.
  • 14.
  • 15. How do rules engines work?
  • 16.
  • 17.
  • 18.
  • 20.
  • 21.  
  • 22.  
  • 24. The Rules... < rule id = &quot;isFemale&quot; > < statement ><![CDATA[ @info.sex equalTo 'Female' ]]></ statement > < actions > < visibleAction questionIDs = &quot;areYouPregnant&quot; /> </ actions > </ rule > < rule id = &quot;isTeenager&quot; > < statement ><![CDATA[ @info.age greaterThanOrEqualTo '13' AND @info.age lessThan '18' ]]></ statement > < actions > </ actions > </ rule > < rule id = &quot;isTeenageGirl&quot; > < statement ><![CDATA[ $isTeenager AND $isFemale ]]></ statement > < actions > < urlAction url = &quot; http://www.seventeen.com &quot; /> </ actions > </ rule >
  • 25. Regular Expressions public static var andOrTrueFalsePattern:RegExp = /AND|OR|true|false/ gi; public static var ruleTokenPattern:RegExp = /([a-zA-Z0-9_]+)/ g; public static var propertyTokenPattern:RegExp = /([a-zA-Z0-9_.]+)/ g; public static var nonSpaceGroups:RegExp = /([a-zA-Z0-9_.'&quot;]+)([^ ])/ gi; public static var quotesPattern:RegExp = /'|&quot;/ gi;
  • 27.
  • 28. Hamcrest API - Matchers: public static const EQUAL_TO:String = &quot;equalTo&quot; ; public static const NOT_EQUAL_TO:String = &quot;notEqualTo&quot; ; public static const LESS_THAN:String = &quot;lessThan&quot; ; public static const LESS_THAN_OR_EQUAL_TO:String = &quot;lessThanOrEqualTo&quot; ; public static const GREATER_THAN:String = &quot;greaterThan&quot; ; public static const GREATER_THAN_OR_EQUAL_TO:String = &quot;greaterThanOrEqualTo&quot; ; public static const CONTAINS:String = &quot;contains&quot; ;
  • 29. Hamcrest API: Get your facts straight! public static function evaluateCondition(target:*, operator:String, source:*):Boolean { try { switch (operator) { case Matchers.EQUAL_TO: assertThat(target, equalTo(source)); break ; case Matchers.NOT_EQUAL_TO: assertThat(target, not(equalTo(source))); break ; case Matchers.LESS_THAN: assertThat(Number(target), lessThan(Number(source))); break ; default : throw new RuleError( &quot;No matcher found for this operator!” ); } } catch (e:Error) { if (e.errorID != RuleError.ILLEGAL_OPERATOR_ERROR) { value= false ; } else { _logger.error(e.message, e.errorID); } }
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35. Basic Algorithm Fact condition A Action Fact cB cC cD AND OR Fact Optimizations can give priority to certain conditions, wait to process until all facts are run through conditions, etc.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.  
  • 42.  
  • 43.
  • 44.
  • 45.
  • 46. Rule XML Sample <!-- Rule definition --> < rule > < getValue key = &quot;Metal Quality&quot; >< containsString value = &quot;Gold&quot; /></ getValue > < addValueOption key = &quot;Metal Finish&quot; value = &quot;Gold-on-Gold&quot; meta = &quot;code:2&quot; /> </ rule >
  • 47. Macro XML Sample: pricing a stone <!-- Macro definition --> < defineMacro name = &quot;priceStone&quot; > < rule > < allOf > < getValue key = &quot;$stoneKey&quot; >< equalTo value = &quot;$stoneValue&quot; /></ getValue > < getValue key = &quot;$stoneSizeKey&quot; >< equalTo value = &quot;$stoneSizeValue&quot; /></ getValue > </ allOf > < addPrice label = &quot;$stoneKey: $stoneValue&quot; amount = &quot;$amount&quot; /> </ rule > </ defineMacro > <!-- Macro implementation --> < priceStone stoneKey = &quot;Royal Stone&quot; stoneValue = &quot;Birthstones - Alexandrite (Jun)&quot; stoneSizeKey = &quot;Royal Stone Size&quot; stoneSizeValue = &quot;12 Point&quot; amount = &quot;4208&quot; />
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54. GBA Rules engine architecture Fact (change event) Conditions Actions User Questions Data Model Binding! Binding! Binding!
  • 55.
  • 56. Question XML < question id = &quot;362&quot; controlType = &quot;ComboBox&quot; inlineHelp = &quot;Does anyone receive money from elsewhere?&quot; label = &quot;Other Employment&quot; optionsID = &quot;R00013&quot; target = &quot;Household.Income.OtherIncome&quot; />
  • 57.
  • 58. Rule XML < rule id = &quot;doesAnyoneHasOtherEmployment&quot; > < statement > $hasOtherEmployment </ statement > < actions > < visibleAction questionGroupIDs = &quot;income_other&quot; /> </ actions > </ rule > < rule id = &quot;NoEmployment&quot; > < statement > $IsOnStrike OR ($NoFutureEmployment AND $NoCurrentEmployment AND $NoPastEmployment AND $NoOtherIncome) </ statement > < actions > < visibleAction questionIDs = &quot;364&quot; /> </ actions > </ rule >
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65. Thanks for obeying. Drew McLean twitter: TunnelVisionary [email_address] RJ Owen twitter: rjowen [email_address]