Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

29
Arden Objects Arden Objects Proposal Proposal Arden SIG Meeting Arden SIG Meeting Jan. 14, 2003 San Antonio, Jan. 14, 2003 San Antonio, Texas Texas Presented by Roger Corman Presented by Roger Corman

Transcript of Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

Page 1: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

Arden Objects ProposalArden Objects ProposalArden SIG MeetingArden SIG Meeting

Jan. 14, 2003 San Antonio, TexasJan. 14, 2003 San Antonio, Texas

Presented by Roger CormanPresented by Roger Corman

Page 2: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

IntroductionIntroduction This proposal follows the McKesson presentation This proposal follows the McKesson presentation

by Tom Hooks at the previous Arden SIG meeting.by Tom Hooks at the previous Arden SIG meeting.

It attempts to incorporate most of the ideas Tom It attempts to incorporate most of the ideas Tom presented in the Phase 3 approach.presented in the Phase 3 approach.

Adds syntax for object definition.Adds syntax for object definition.

Adds more formalism (B/N Forms)Adds more formalism (B/N Forms)

Page 3: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

Introduction (cont.)Introduction (cont.)This is still an incomplete proposal: a few issues are This is still an incomplete proposal: a few issues are not covered and presumably will be topics of not covered and presumably will be topics of discussion.discussion.

Page 4: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

GoalsGoals Simplify handling of query results.Simplify handling of query results.

Keeping query results as a list of objects/records is Keeping query results as a list of objects/records is often more convenient and intuitive. often more convenient and intuitive.

Creates a standard way to have named Creates a standard way to have named object/attributes in the system. This may allow object/attributes in the system. This may allow platform-specific extensions to other objects to still platform-specific extensions to other objects to still share much of the object manipulation logic.share much of the object manipulation logic.

Maintain backward compatibility.Maintain backward compatibility.

Page 5: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

Language GoalsLanguage Goals Keep added syntax/reserved words to a minimum.Keep added syntax/reserved words to a minimum.

Any changes should work with existing Arden as Any changes should work with existing Arden as seamlessly as possible.seamlessly as possible.

Coax the objects out of Arden, rather than impose Coax the objects out of Arden, rather than impose a new model.a new model.

Simplicity.Simplicity.

Page 6: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

Object Declaration StatementObject Declaration StatementThe OBJECT statement definition:The OBJECT statement definition:

<var> := OBJECT [ <field-name-1>, <field-name-<var> := OBJECT [ <field-name-1>, <field-name-2> ... ];2> ... ];

LET <var> BE OBJECT [ <field-name-1>, <field-LET <var> BE OBJECT [ <field-name-1>, <field-name-2> ... ];name-2> ... ];

Field names are Arden identifiers.Field names are Arden identifiers.

Example:Example: MedicationDose := object [Medication, Dose, MedicationDose := object [Medication, Dose,

Status];Status];

Page 7: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

Object Declaration Statement Object Declaration Statement (cont.)(cont.)

Object declaration statements can only occur in the Object declaration statements can only occur in the Data Slot, and they must occur prior to any use of the Data Slot, and they must occur prior to any use of the object type. This is similar to an MLM or object type. This is similar to an MLM or DESTINATION declaration.DESTINATION declaration.

Page 8: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

Object Declaration: Object Declaration: Syntax ModificationsSyntax Modifications

Add OBJECT as an Arden reserved word. This is the Add OBJECT as an Arden reserved word. This is the only new reserved word being proposed, and only new reserved word being proposed, and possibly the only backward compatibility issue.possibly the only backward compatibility issue.

Page 9: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

Object Declaration: Object Declaration: Syntax ModificationsSyntax Modifications

In <data_assign_phrase>, added OBJECT option:In <data_assign_phrase>, added OBJECT option:

<data_assign_phrase> ::=<data_assign_phrase> ::= "READ" <read_phrase>"READ" <read_phrase>| "MLM" <term| "MLM" <term| "FUNCTION" <term| "FUNCTION" <term| "MLM" <term> "FROM" "INSTITUTION" <string>| "MLM" <term> "FROM" "INSTITUTION" <string>| "EVENT" <mapping_factor>| "EVENT" <mapping_factor>| "OBJECT" <object_definition>| "OBJECT" <object_definition>| "MESSAGE" <mapping_factor>| "MESSAGE" <mapping_factor>| "DESTINATION" <mapping_factor>| "DESTINATION" <mapping_factor>| "ARGUMENT"| "ARGUMENT"| "ARGUMENT" <number>| "ARGUMENT" <number>| <call_phrase>| <call_phrase>| <expr>| <expr>

Page 10: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

Object Declaration: Object Declaration: Syntax ModificationsSyntax Modifications

Added <object_definition>:Added <object_definition>:

<object_definition> ::=<object_definition> ::= "[" <object_attribute_list> "]""[" <object_attribute_list> "]"

Added <object_attribute_list>:Added <object_attribute_list>:

<object_attribute_list> ::=<object_attribute_list> ::= <identifier><identifier> | <identifier> "," <object_attribute_list>| <identifier> "," <object_attribute_list>

Page 11: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

Object Attribute ReferencesObject Attribute References Implement “dot notation” for referring to attributes Implement “dot notation” for referring to attributes

of objects.of objects.

If an object attribute contains another object, the If an object attribute contains another object, the dots can be strung together.dots can be strung together.

Example:Example:

patient.weight.unitspatient.weight.units

Page 12: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

Object Attribute References:Object Attribute References:Dot OperatorDot Operator

9.12.xx Dot (binary)

The dot (.) operator is used to select an attribute from an object, based on the name following the dot.

It takes an expression and an identifier. The expression It takes an expression and an identifier. The expression typically evaluates to a structure or a list of structures.typically evaluates to a structure or a list of structures.

Its usage is:<n:any-type> := <expr> . <identifier>

If the expression does not evaluate to an object, null is returned.

If the expression evaluates to a list, normal Arden list handling is used and a list is returned.

Page 13: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

Object Attribute References:Object Attribute References:Dot Operator (cont.)Dot Operator (cont.)

Dot Operator Example:

NameType := object [FirstName, MiddleName, LastName];

/* Assume namelist contains a list of 3 NameType objects */

(“John”, “Paul”, “George”) := namelist.FirstName;(“Lennon”, “McCartney”, “Bush”) := namelist.LastName;“John” := namelist[1].FirstName; null := namelist[1].Height;(null, null, null) := namelist.Height;

Page 14: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

Object Attribute References:Object Attribute References:Syntax ModificationsSyntax Modifications

Added “.” operator. This is at the same precedence level as the Added “.” operator. This is at the same precedence level as the Element operator. Element operator.

<expr_factor> ::=<expr_factor> ::= <expr_factor_atom><expr_factor_atom> | <expr_factor_atom> "[" <expr> "]" | <expr_factor_atom> "[" <expr> "]" | <expr_factor> "." <identifier> | <expr_factor> "." <identifier>

Page 15: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

READ AS StatementREAD AS Statement READ AS is a structured READ.READ AS is a structured READ.

Instead of returning a list of columns from a query, Instead of returning a list of columns from a query, it returns a list of rows (objects).it returns a list of rows (objects).

The returned objects will match the type specified.The returned objects will match the type specified.

<var> := READ AS <object-type> <aggregation> <mapping> WHERE <constraint>;

LET <var> BE READ AS <object-type> <aggregation> <mapping> WHERE <constraint>;

Page 16: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

READ AS Statement: READ AS Statement: Syntax ModificationsSyntax Modifications

In <data_assign_phrase>, added READ AS option:In <data_assign_phrase>, added READ AS option:

<data_assign_phrase> ::=<data_assign_phrase> ::= "READ" <read_phrase>"READ" <read_phrase>| "READ" “AS” <identifier> <read_phrase>| "READ" “AS” <identifier> <read_phrase>| "MLM" <term| "MLM" <term| "FUNCTION" <term| "FUNCTION" <term| "MLM" <term> "FROM" "INSTITUTION" <string>| "MLM" <term> "FROM" "INSTITUTION" <string>| "EVENT" <mapping_factor>| "EVENT" <mapping_factor>| "OBJECT" <object_definition>| "OBJECT" <object_definition>| "MESSAGE" <mapping_factor>| "MESSAGE" <mapping_factor>| "DESTINATION" <mapping_factor>| "DESTINATION" <mapping_factor>| "ARGUMENT"| "ARGUMENT"| "ARGUMENT" <number>| "ARGUMENT" <number>| <call_phrase>| <call_phrase>| <expr>| <expr>

Page 17: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

READ AS Example 1READ AS Example 1Example:Example:

MedicationDose := object [Medication, Dose, Status];MedicationDose := object [Medication, Dose, Status];

med_doses := read as MedicationDose med_doses := read as MedicationDose { select med, dosage, status from client where status != "inactive" }; { select med, dosage, status from client where status != "inactive" };

write med_doses;write med_doses;

/* outputs something like the following *//* outputs something like the following */

[MedicationDose: Medication="Med1", Dose="Dose1", Status="Active"],[MedicationDose: Medication="Med1", Dose="Dose1", Status="Active"],[MedicationDose: Medication="Med2", Dose="Dose2", Status="Active"],[MedicationDose: Medication="Med2", Dose="Dose2", Status="Active"],[MedicationDose: Medication="Med3", Dose="Dose3", Status="Active"][MedicationDose: Medication="Med3", Dose="Dose3", Status="Active"]

write med_doses.Medication;write med_doses.Medication;

/* outputs *//* outputs */

"Med1", "Med2", "Med3""Med1", "Med2", "Med3"

Page 18: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

READ AS Example 2READ AS Example 2Example:Example:

MedicationDose := object [Medication, Dose, Status];MedicationDose := object [Medication, Dose, Status];

med_doses := read as MedicationDose med_doses := read as MedicationDose last ({ select med, dosage, status from client where status != "inactive" }last ({ select med, dosage, status from client where status != "inactive" }

where it occurred within the past 2 weeks);where it occurred within the past 2 weeks);

write med_doses;write med_doses;

/* outputs something like the following *//* outputs something like the following */

[MedicationDose: Medication="Med3", Dose="Dose3", Status="Active"][MedicationDose: Medication="Med3", Dose="Dose3", Status="Active"]

Page 19: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

Primary TimePrimary TimeAttributes retain primary times, and expressions like:Attributes retain primary times, and expressions like:

TIME OF Renal_function.BUN_levelTIME OF Renal_function.BUN_level

will work as expected.will work as expected.

To be decided: Should objects have a primary To be decided: Should objects have a primary time?time?

Page 20: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

Filtering Lists of ObjectsFiltering Lists of Objects WHERE clause supports lists of objects.WHERE clause supports lists of objects.

Attributes can be appended to "it" and "they" synonyms.Attributes can be appended to "it" and "they" synonyms.

// List of objects returned// List of objects returned

Bp_r_arm := bp where it.site = "R Arm“;Bp_r_arm := bp where it.site = "R Arm“;

// Simple list returned// Simple list returned

Elevated_systolic := bp.systolic where it > 140;Elevated_systolic := bp.systolic where it > 140;

Page 21: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

Remaining IssuesRemaining Issues Object TimeObject Time

Object ValueObject Value

Assignment to attributesAssignment to attributes

Assignment of objects (by value vs. by reference)Assignment of objects (by value vs. by reference)

Behavior of other operators when passed objects. Behavior of other operators when passed objects. Most operators will only support attributes, and will Most operators will only support attributes, and will treat an object as an unknown type. A few may treat an object as an unknown type. A few may need some appropriate behavior.need some appropriate behavior.

Page 22: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

Operator ModificationsOperator ModificationsAggregation operators such as LATEST, EARLIEST, Aggregation operators such as LATEST, EARLIEST, MINIMUM, MAXIMUM can easily be applied to an MINIMUM, MAXIMUM can easily be applied to an attribute of a list of objects:attribute of a list of objects:

Max := maximum of obj_list.attr1;Max := maximum of obj_list.attr1;

However, Max now contains only the attribute value, However, Max now contains only the attribute value, not the object itself. We should probably specify how not the object itself. We should probably specify how and when the object itself may be returned.and when the object itself may be returned.

Page 23: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

SORTSORTWe should specify a way to sort on any field.We should specify a way to sort on any field.

Sorted_list := sort <attr> data unsorted_list;Sorted_list := sort <attr> data unsorted_list;

Where <attr> could be any attribute, and the sorted Where <attr> could be any attribute, and the sorted list returned is a list of objects.list returned is a list of objects.

Page 24: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

Object TimeObject TimeWe may want to define a time for the object, so:We may want to define a time for the object, so:

TIME of objTIME of objis a reasonable expression.is a reasonable expression.

This allows LATEST and EARLIEST to work as This allows LATEST and EARLIEST to work as expected, and helps make object use simpler in other expected, and helps make object use simpler in other places as well.places as well.

Perhaps if all fields have the same time, this Perhaps if all fields have the same time, this automatically becomes the object time, otherwise it is automatically becomes the object time, otherwise it is null.null.

Page 25: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

Object ValueObject ValueIn McKesson’s presentation, they suggested a In McKesson’s presentation, they suggested a default Value field, which would be used if no default Value field, which would be used if no attribute was specified when objects were passed to attribute was specified when objects were passed to Arden operators.Arden operators.

I have some questions about this i.e. what if a list I have some questions about this i.e. what if a list contains some objects and some non-objects. Does contains some objects and some non-objects. Does the value field of the objects get taken and the non-the value field of the objects get taken and the non-objects used directly? We need to think about this a objects used directly? We need to think about this a bit.bit.

Page 26: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

Assignment of AttributesAssignment of AttributesIt is easy to implement assignment of attributes i.e. It is easy to implement assignment of attributes i.e. the left side of an assignment statement can use the the left side of an assignment statement can use the dot notation. dot notation.

However, this comes back to the question of However, this comes back to the question of value/reference semantics which we brought up last value/reference semantics which we brought up last meeting but has not been resolved. meeting but has not been resolved.

Page 27: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

Assignment of Attributes Assignment of Attributes (cont.)(cont.)

Example:Example:

Assume x is an object with attribute a.Assume x is an object with attribute a.

y := x;y := x;x.a := 10;x.a := 10;

Question: Did y.a get modified?Question: Did y.a get modified?

If we assume reference semantics of objects, then y.a also got If we assume reference semantics of objects, then y.a also got modified. If we assume value semantics, then x.a and y.a modified. If we assume value semantics, then x.a and y.a are separate variables.are separate variables.

I believe that reference semantics is more useful, powerful and I believe that reference semantics is more useful, powerful and convenient. It is used in most OO languages such as Java, convenient. It is used in most OO languages such as Java, C#, C++ (typically but not always since both are allowed), C#, C++ (typically but not always since both are allowed), Common Lisp, VB.NET, Smalltalk, etc.Common Lisp, VB.NET, Smalltalk, etc.

Page 28: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.

Creation of ObjectsCreation of ObjectsIt would be useful to be able to construct objects on It would be useful to be able to construct objects on

the fly, rather than having to use lists to simulate the fly, rather than having to use lists to simulate them (as is typically done now).them (as is typically done now).

I have not proposed a syntax for object construction.I have not proposed a syntax for object construction.

The only way to obtain objects in this proposal is via The only way to obtain objects in this proposal is via the READ AS statement.the READ AS statement.

Page 29: Arden Objects Proposal Arden SIG Meeting Jan. 14, 2003 San Antonio, Texas Presented by Roger Corman.