Presentation is loading. Please wait.

Presentation is loading. Please wait.

© Donald F. Ferguson, 2014. All rights reserved. Topics in Computer Science: Modern Internet Service Oriented Application Development Lecture 8: IPaaS.

Similar presentations


Presentation on theme: "© Donald F. Ferguson, 2014. All rights reserved. Topics in Computer Science: Modern Internet Service Oriented Application Development Lecture 8: IPaaS."— Presentation transcript:

1 © Donald F. Ferguson, 2014. All rights reserved. Topics in Computer Science: Modern Internet Service Oriented Application Development Lecture 8: IPaaS and Rules Programming Dr. Donald F. Ferguson Donald.Ferguson@software.dell.com (Admin: Becky_McCord@dell.com)

2 2 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Contents

3 3 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Contents A couple of Boomi/ESB patterns –Select Distinct –Lookup tables –Simple Join Rules programming –Conceptual model and motivation –Tools –Some simple approaches to rules –Decision tables –Decision trees –Some rules –Observations Discussion and final project

4 4 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming A Couple of Boomi/IPaaS Patterns

5 5 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Select Distinct and Table Lookup Problem statement: I have a spreadsheet with rows for students in the class. I want to: –Find the set of schools, with one entry for each school. A given school may have several students in the class. –Map the distinct school codes to “human readable names.”

6 6 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Simple Join We have seen manipulation of single documents, e.g. –PROJECT (do not pass fields through maps). –Transform between profile types, and between schema. –Operations on fields, e.g. trim whitespace. How do I JOIN two documents into a single document? For example, –…/posts (blog) posts have user ID, title, comment, etc. –…/users has user ID and name –I want a single document with {user name, post ID, title} that merges information from two sets of documents. JOIN activity/steps JOIN clause SELECT posts.*, users.username FROM posts INNER JOIN users WHERE posts.userid==users.id

7 7 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Rules Programming

8 8 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Conceptual Model

9 9 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Flexible Implementation – Some of which we will Cover REST Imperative languages Java PHP JavaScript “Programming in the Large:” State changes Graph based orchestration of “Programming in the Small” Using BPMN and Activit ESB/Data/Message Flows: Route Split Map/transform Using Boomi. Now it’s time for Business rules.

10 10 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Rule and Rule Set A rule is a statement of the form –IF (When) (…) –THEN { s1; s2; …} A rule set –Is a set of rules –Sharing a set of objects –That are the scope of IF –And what s1, … change. Isn’t this just “code?” –Well yes, but in “code” –The rule flow is fixed by the order and nesting of “if … then … else …}. –The rule set is fixed by what you entered in Eclipse/emacs and compiled. –In a rule engine, the engine –Reads a data file containing rules and facts. –And there is an API for dynamically adding rules and facts to a running engine. –Similar to the way Activiti reads an XML file defining a process.

11 11 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Why Use a Rule Engine? Flexibility Sometimes, you can write down all the rules but cannot easily figure out which ones to apply when and in which order, and you sometimes figure out new rules by watching the answer the running system produces. Logic and Data Separation Breaking your domain objects from business rules can lead to a much easier to maintain application as it can shield from changes in the future, since the logic is all laid out in rules. Speed and Scalability Many times we apply "if" conditions that we didn't really need. The Rete algorithm, as implemented by Drools, replaces all of the if... then statements with an optimized network. Centralization of Knowledge By using rules, you create a repository of knowledge (a knowledgebase) which can be considered as a single point of truth, for business policy (for instance) - ideally rules are so readable that they can also serve as documentation Tool Integration Writing rules means also to get accustomed with Rule language, validation and debugging. Eclipse provide an excellent tool to deliver and test your Rules. Understandable Rules Using tools and rule templates facilitates collaborative design of business policy/rules between business professionals and software developers, similar to how BPMN facilitates collaborative design of business processes.

12 12 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Rules Engine – Drools (xxx.drl) Load rules and facts Modify rules and facts.

13 13 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Tools

14 14 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Three Core Concepts Editor Tools Rule Set “xxx.drl” file “Engine”

15 15 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Structured Text Rule Definition Business professionals (or others) can provide the high-level structure for rules Using a “constrained” language with predefined “words” and “clauses,” e.g. –“There exists” –“An {x} with property {y}” –“Property {p} of {x} is …” The editor has popups allowing selection of valid terms, words, clauses, etc. The tool “generates” the “code” for final implementation by a programmer.

16 16 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Rich Developer Tools

17 17 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Debugger Reveals Big Picture Current rule/thread. Location in source. Variables for the rule. Inferencing graph. What rules and working memory changes got me here. Current working memory.

18 18 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Some Simple Rule Models

19 19 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Decision Table Suppose –I have a load application with properties period, amount, … –And want to produce approved/denied, rate, … A very common, intuitive is “look it up in a table.”

20 20 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Decision Table Tool

21 21 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Maps To/From Intuitive, Understood Spreadsheet Model

22 22 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Decision Table Intuitive model for combining reusable rules that mirrors a common way people think about solving a problem.

23 23 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Some Rules

24 24 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Rule and Example

25 25 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Some “ When ” Examples

26 26 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Some More Examples

27 27 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Some More Examples

28 28 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Some More Examples

29 29 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming You Get the Picture The working memory is a set of –JavaBean classes. –A set of instances of the class. There is a query language for building query statements –Finding an instance of a type whose properties match a pattern. –Boolean combinations in statements. –Existence and non-existence. –etc. You can bind variables to a properties of a matched fact for use in subsequent statements. But remember, every (power) set of facts that meets the “When” condition is logically chosen for the rule, e.g. –$c : Cat() –$d : Dog() matches every pair of a Dog and a Cat.

30 30 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming “ Then ” Example

31 31 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming “ Then ” The “Then” clause can be –Pretty much any Java code. –And has access to “facts” that were matched in the “When” clause. There are some guidelines/best practices –Avoid –if … then … else … and similar constructs. –While … –For … and other control flow constructs because adding control flow to a “declarative, no explicit control” programming model defeats the whole purpose. –Typically, then “When” clause –Creates, removes or changes properties of facts. –Invokes “services APIs”

32 32 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Semantic Web Application Platform – SWAP “ The Modern Internet Perspective ” Resource Description Framework (RDF) Is a language for representing information about “resources” in the World Wide Web. Treats the WWW liked a gigantic, typed web of facts As opposed to a web of documents.

33 33 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Semantic Web Application Platform – SWAP “ Cwm is the Modern Internet Rules Perspective ” Cwm (pronounced coom) is –A general-purpose data processor for the semantic web –It is a forward chaining reasoner which can be used for –Querying –Checking –Transforming –Filtering information (RDF)

34 34 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Some Examples

35 35 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Observations General observations –Rules is a popular and powerful approach to implementing services. –There are a lot of languages, engines and models. –Rules are a powerful way of “collaboration” between –Business professionals. –Engineering/SW developers. –The full power can be complex and counter-intuitive. –But there are some very models that are very intuitive, e.g. Decision Tables. The Internet/web has an emerging model similar to rules –Resource Description Framework –Web Ontology Language (OWL) –Closed World Model (Cwm) –N3 – RDF serialization Exciting, but not sure how much uptake is really happening.

36 36 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Final Project

37 37 © Donald F. Ferguson, 2015. All rights reserved.Modern Internet Service Oriented Application Development – Lecture 9: IPaaS Continued and Rules Programming Final Project Implement a REST service using a rule engine of your choice. –The implementing is a rule file that you load, e.g. a.drl file. –The working memory –Is a set of resource types –A set of resource instances –The REST API CRUDs resource instances. –Which triggers the rule engine to modify facts in working memory. –Enabling GET to retrieve new and/or updated facts. Your solutions must have –3 simple resource types of your choice. –10 simple rules. –You can start with one of the many examples. This is a group project. One project/team.


Download ppt "© Donald F. Ferguson, 2014. All rights reserved. Topics in Computer Science: Modern Internet Service Oriented Application Development Lecture 8: IPaaS."

Similar presentations


Ads by Google