Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ralph Johnson - University of Illinois1 Reflection and the Adaptive Object Model Architecture Ralph Johnson University of Illinois at Urbana-Champaign.

Similar presentations


Presentation on theme: "Ralph Johnson - University of Illinois1 Reflection and the Adaptive Object Model Architecture Ralph Johnson University of Illinois at Urbana-Champaign."— Presentation transcript:

1 Ralph Johnson - University of Illinois1 Reflection and the Adaptive Object Model Architecture Ralph Johnson University of Illinois at Urbana-Champaign johnson@cs.uiuc.edu 217-244-0093 http://st-www.cs.uiuc.edu/users/johnson

2 Ralph Johnson - University of Illinois2 Reflection l Is hard l Is important l The ability of a program to reason about and change its own implementation.

3 Ralph Johnson - University of Illinois3 Reflection Base level (the application) Meta level (the virtual machine) Paycheck Printer Report Module Employee Class Method

4 Ralph Johnson - University of Illinois4 Patterns and Architecture Problem with Pattern-Oriented Software Architecture is that the “architectural patterns” are really pattern languages, not patterns.

5 Ralph Johnson - University of Illinois5 Kinds of Architectures Client-server Purpose: access shared data, distribute computation Result: bottlenecks usually database or network, not CPU

6 Ralph Johnson - University of Illinois6 Kinds of Architectures Layered system Purpose: reuse lower layers limit effects of change make system easier to understand Result: can be inefficient fix bottlenecks by “punching hole” thru layers

7 Ralph Johnson - University of Illinois7 Adaptive Object Model l Pattern of business software l Used to model information l Valuable where information structure is complex and changes rapidly l Can be inefficient and hard to understand

8 Ralph Johnson - University of Illinois8 Adaptive Object Model l Made up of design patterns »Composite, Strategy, Interpreter »Type Object »Properties l Examples: »Rating insurance policies »Rating telephone calls »Maintaining database

9 Ralph Johnson - University of Illinois9 Type Object l Problem: Have to subclass, and subclasses require code. Want to customize system without programming. l Solution: »For each kind of object, make two classes, an Instance and a Type. »Try not to make a subclass - make a new object of the Type.

10 Ralph Johnson - University of Illinois10 Examples l Airline scheduling system »airplane and airplane type l Medical information system »observation and observation type l Manufacturing »item and item type

11 Ralph Johnson - University of Illinois11 Type Object l “type” describes what a group of objects have in common l often “type” creates “instances” l often used with Strategy, Interpreter, and Property InstanceType name values name strategies properties type

12 Ralph Johnson - University of Illinois12 Insurance Policies Instead of using multiple inheritance to model policies, model a policy as a tree of components. House address, value, size, style House address, value, size, style Liability limit, deductable Liability limit, deductable Car value, mileage, age, drivers Car value, mileage, age, drivers Policy owner, address Policy owner, address Fire limit, deductable Fire limit, deductable Liability limit, deductable Liability limit, deductable Collision limit, deductable Collision limit, deductable

13 Ralph Johnson - University of Illinois13 Component Class Hierarchy One solution is to make a class for each kind of component. PolicyComponent CarHouseHouseFireHouseLiability CarFireCarLiability Policy

14 Ralph Johnson - University of Illinois14 Component Characteristics Insurance policies have only a few operations »Edit - create new policy or change old one »Rate - compute amount to charge for policy »Print - convert into paper Different components have different attributes

15 Ralph Johnson - University of Illinois15 Eliminating Subclasses l Policy made up of Components and ComponentTypes. l Each ComponentType defines a set of Strategies (to represent operations) l Component has a set of Properties (to represent attributes). l One Component class and one ComponentType class.

16 Ralph Johnson - University of Illinois16 Property Problem: object has arbitrary or huge number of attributes Solution: represent attributes with a dictionary SubjectProperty name value properties

17 Ralph Johnson - University of Illinois17 Composite Type Object with Properties and Strategies Component ComponentType name Property value PropertyType name type Strategy type properties children

18 Ralph Johnson - University of Illinois18 Composite Type Object with Properties and Strategies Component Strategy Property value = ‘1 Main Street, Big City’ Property value = ‘1 Main Street, Big City’ PropertyType name =‘address’ PropertyType name =‘address’ ComponentType name =‘House’ ComponentType name =‘House’ PropertyType name =‘owner’ PropertyType name =‘owner’ Property value =‘John Doe’ Property value =‘John Doe’ Auto ComponentType name =‘Policy’ ComponentType name =‘Policy’ Component

19 Ralph Johnson - University of Illinois19 Problem: Strategy leads to a big class hierarchy, one class for each kind of policy. Solution: Make Composite Strategies. => Interpreter pattern

20 Ralph Johnson - University of Illinois20 Interpreter Pattern Problem: Need a small language Solution: »Make class hierarchy that models the grammar »Each class defines a value() function with the context as the argument »Program is a tree of objects

21 Ralph Johnson - University of Illinois21 Small Language for Insurance l Attributes - value() function for an Attribute Type will return value of an attribute with that type in the context. l Arithmetic expressions (+,-,*,/) l Table lookup l Assignment to attribute

22 Ralph Johnson - University of Illinois22 Component ComponentType name Property value PropertyType name type Rule type children properties Table Expression type children Type Object Composite Strategy Interpreter Property CompositeType Object

23 Ralph Johnson - University of Illinois23 Products l A product is a type of policy. l Framework makes it easy to create new kind of product. l Framework makes composite types. l Instance vs. type l Operational vs. knowlege

24 Ralph Johnson - University of Illinois24 Editing a Policy l One editor can edit any policy. l Policy is a sequence of components. l Policy editor is a sequence of component editors. l Component editor has a field for each attribute in the component. »Number field »date field

25 Ralph Johnson - University of Illinois25 Creating New Component ComponentType name =‘Liability’ ComponentType name =‘Liability’ Component ComponentType name =‘Policy’ ComponentType name =‘Policy’ Component ComponentType name =‘House’ ComponentType name =‘House’ ComponentType name =‘Auto’ ComponentType name =‘Auto’ ComponentType name =‘Liability’ ComponentType name =‘Liability’

26 Ralph Johnson - University of Illinois26 Creating New Component l When editing component of type T, you can create a component of any type that is a child of T. l Types act like a grammar, while components are an abstract syntax tree

27 Ralph Johnson - University of Illinois27 Advantages of AOM l Automate user interface l Automate database interface l Enable users to extend system l Automate other aspects of system »History »Workflow

28 Ralph Johnson - University of Illinois28 Insurance Framework Summary l Policy is a tree of components l Component type is a composite object l System has tools for editing policies, and tools for editing component types l Domain specific object model is in the database, not the CASE tool.

29 Ralph Johnson - University of Illinois29 Adaptive Object Model l Many systems store object model in a database and interpret it »results in user extensible systems »flexible, easy to maintain »kernel is small, abstract, complex »performance is an issue

30 Ralph Johnson - University of Illinois30 AOM and Reflection l Similarities »Base level and meta level »Developers have to know both levels l Differences »Base level doesn’t necessarily invoke meta level »No “reflective tower”

31 Ralph Johnson - University of Illinois31 Telecommunications Billing l Database »customers »charges »network events (call, directory assistance, voice-mail) »billing plans »bills

32 Ralph Johnson - University of Illinois32 Telecommunications Billing Rating - converting network events into charges to customer Billing - computing discounts, finance charges, etc - printing bills

33 Ralph Johnson - University of Illinois33 Rating l Many kind of network events l Billing policy determines how to rate network events l Billing policies continually changing l Network event has a set of properties

34 Ralph Johnson - University of Illinois34 Rating Account Billing Policy BusinessEvent name = ‘information’ BusinessEvent name = ‘information’ BusinessEvent name = ‘phone call’ BusinessEvent name = ‘phone call’ Charge value = ‘roaming *.25’ Charge value = ‘roaming *.25’ Charge value = ‘air time *.05’ Charge value = ‘air time *.05’ Property name = ‘caller’ value = ‘217-345-1111’ Property name = ‘caller’ value = ‘217-345-1111’ Network Event name = ‘phone call’ Network Event name = ‘phone call’ Property name = ‘air time’ value = ‘25’ Property name = ‘air time’ value = ‘25’

35 Ralph Johnson - University of Illinois35 Rating Algorithm l Given a Network Event, find the Account, then the Billing Policy. l Find the Business Event with the same name as the Network Event. l Compute the total of the Charges for the Business Event by evaluating them in the context of the Business Event.

36 Ralph Johnson - University of Illinois36 NetworkEvent Type name Property name value NetworkEventType BusinessEvent BusinessEventType Charge +*PropertyRef Entity Properties type Interpreter Type Object

37 Ralph Johnson - University of Illinois37 Similarities Between Systems l Automate GUIs l Automate database access l Provide full history on all objects l Provide GUIs for editing types and rules. l Planned for customers to edit types, but they don’t.

38 Ralph Johnson - University of Illinois38 Differences Between Systems l Phone billing system makes lots of subclasses of Entity and Type l Phone billing system has more complex algorithms l Insurance system has more powerful rules

39 Ralph Johnson - University of Illinois39 Global Data l Database for factory locations, product types, accounting codes, conversion rates, etc. l Originally 10 tables, now 100. l Keeps complete history of data l Global Data Division in charge of schemas and data editing programs, their users are in charge of the data.

40 Ralph Johnson - University of Illinois40

41 Ralph Johnson - University of Illinois41 History l Effective date - data at which record is valid l Obsolete date - date at which record is invalid l Record is never deleted, its obsolete date is just set to yesterday. l Referential integrity

42 Ralph Johnson - University of Illinois42 Global Data Editor Window Description Table name Attribute name type Widget value RecordValidator Window Properties Type Object Record Field name value Type Object FieldValidator Widget Description Type Object Strategy

43 Ralph Johnson - University of Illinois43 Result l Instead of 200 COBOL programs, there are two Java programs (client and server) l We use XML for metadata (window specs and table specs) l Generate documentation from XML l Programs make type objects from XML l New validation rules are in Java

44 Ralph Johnson - University of Illinois44 Adaptive Object Models l It is common to see combinations of Type Object, Composite, Property, Strategy, and Interpreter. l Object model stored in the database. l Editors / database interface driven by object model. l Enables system to be customized easily.

45 Ralph Johnson - University of Illinois45 Disadvantages of AOM l Abstract - can be hard to learn l An interpreter - can be slow l A language - are you ready to write a debugger, a test harness, a configuration control system, documentation aids, etc?

46 Ralph Johnson - University of Illinois46 The Poetry of the Language “It is possible to put patterns together in such a way that many many patterns overlap in the same physical space: the building is very dense; it has many meanings captured in a small space; and through this density, it becomes profound.” Christopher Alexander “A Pattern Language”

47 Ralph Johnson - University of Illinois47 Summary l Interesting applications use many patterns l Many interesting patterns are not in Design Patterns l Particular combinations of patterns are architectures, and interesting in their own right.

48 Ralph Johnson - University of Illinois48 Summary l Document architectures l Patterns are a good model for documentation »architecture is a pattern? »architecture is a set of patterns? »architecture is an application of a set of patterns?

49 Ralph Johnson - University of Illinois49 For more information on adaptive object models and other architectures for business software, see http://st-www.cs.uiuc.edu/users/johnson /bus-obj.html


Download ppt "Ralph Johnson - University of Illinois1 Reflection and the Adaptive Object Model Architecture Ralph Johnson University of Illinois at Urbana-Champaign."

Similar presentations


Ads by Google