330 likes | 359 Views
SMUG 2001 Execution in UML. May 7-9, 2001 Westward Look Resort Tucson, Arizona. Implicit Bridging: From Theory into Practice. Campbell McCausland Director, Research and Development Project Technology. Objects have delivered Reuse !. . . . . or have they ?
E N D
SMUG 2001Execution in UML May 7-9, 2001 Westward Look Resort Tucson, Arizona
Implicit Bridging:From Theory into Practice Campbell McCausland Director, Research and Development Project Technology
Objects have delivered Reuse ! • . . . . or have they ? • In practice, the statistics don’t look so good. • . . . . except in areas with large user bases such as GUI and Container classes. • In particular, companies are not able to reuse their own Intellectual Property. • Why is this ?
Why Objects don’t deliver Reuse (on their own) ? • Without a process which focuses on delivering Reuse through Subject Matter Separation . . . • . . . Reuse requires the best, most disciplined engineers . . . • . . . and it takes longer . . . • . . . to date, the preserve of the specialists who make class libraries for mass use.
Existing Bridging Strategies • Use explicit Bridge Calls between domains. • . . . not always necessary . . . • . . . only required when temporal causality is involved . . . • . . . but even then, why should the Analyst be made aware anything special is going on ?
What’s right with Explicit Bridges ? • Easy to Understand • Easy to Use • Easy to Document
What’s wrong with Explicit Bridges ? • Coupling, that’s what. • Any time an explicit interface is used a small amount of coupling is created . . . • . . . even where tools go to great lengths to support the separation of subject matters.
Conclusion: Avoid Explicit Bridging ! • BUT, Q: What do we do instead ? • A: The Architecture/Translator automatically inserts the necessary Bridging implementation. • Q: Excuse me? How ? • A: By following either a mapping rule or an enumerated mapping table called a Half Table.
Abstract Example • The code automation process generates get{attribute.Name} and set{attribute.Name} accessor functions. • These normally just set or return the appropriate value in the memory allocated to the instance. • But we have control over the translator, it could read a table and sometimes generate something different if we wished.
Domain Types • Application • Service • Architecture • Implementation
Application • Uses Bridges to other Domains to interface with concrete technology and the real world. • Code is generated purely through the Architecture.
Service • Two types, ‘Pure’ and ‘Hybrid’ • ‘Pure’; has code generated only through the Architecture. Example:- Alarms • ‘Hybrid’; has code generated via the Architecture from its models, but it also has ‘Impedance Matching’ archetypes which generate code to interface with a particular technology. Example:- AUI Domain
Architecture and Implementation • Architecture • Defines the Structure for Data and Control of the System. • Implementation • Inherently simple. • Modeled structure, but typically no modeled behavior. • All code is generated by ‘Impedance Matching’ archetypes.
Pure and Impedance Matched Bridging • Implicit bridging works differently depending on the type of Domains being mapped:- • Mappings between ‘Pure’ or ‘Hybrid’ Domains; necessary code is generated by extensions to the Architecture. • Mappings between a ‘Pure’ or ‘Hybrid’ and an Implementation Domain; ‘Impedance Matching’ code generates Architecture compatible code which accepts or initiates required threads of control.
A Concrete Example from ODMS • The Robot in the ODMS uses stepper motors to control its movement. • We would like to map the X, Y, Z and Theta position attributes to PIO Registers for Stepper Motor Control. • In this simple example, PIO will be treated as a ‘Hybrid’ Service Domain.
How to Bridge . . . . Client Client.Server.brg Requirements Server.ifc Capabilities Server
PIO.ifc .include “ARCH.ifc” .// .function FieldAsAttribute .param frag_ref Field .param frag_ref Attr .param frag_ref NavSpec .// Body Elided .end function .// .// .function VectoredInterruptAsEvent .param frag_ref Interrupt .param frag_ref Event .param frag_ref NavSpec .// Body Elided .end function
ODMS.PIO.brg .include “ARCH.ifc” .include “ODMS.pei” .include “PIO.ifc” .// .// Locate Client Domain Objects .invoke clDom = get_domain(“ODMS”) .invoke robot = get_object(clDom, “Robot”) .invoke x_posn = get_attribute(robot, “X Position”) .// .// Create Pre-existing Instances .invoke robot1 = createrobot() .invoke stepReg1 = createregister(“Stepper1”, “0xFFF1”, 16, “IO”) .invoke XFld = createfield(stepReg1, “X”, 8, 0, FALSE, “WO”) .invoke YFld = createfield(stepReg1, “Y”, 8, 0, FALSE, “WO”) .// .// Map interrupt ‘X Positon’ and ‘Y Position’ onto ‘Stepper 1’ .invoke NavSpec = createnavigationSpecification() .invoke idr = PreExstCtptObj(“stepRegister 1 to Robot”, robot1, stepReg1) .invoke createinterDomainReference(NavSpec, idr) .invoke FieldAsAttribute(XFld, x_posn, NavSpec) .invoke FieldAsAttribute(YFld, y_posn, NavSpec)
Unmapped Architectural Code /******************************************************************** Function name : D_R_set_Actual_x_coordinate Author : Date : Return Desc. : Description : *********************************************************************/ void D_R_set_Actual_x_coordinate(robot_c * robot, unsigned int value) { robot->Actual_x_coordinate = value ; }
Mapped Architectural Code /******************************************************************** Function name : D_R_set_Actual_x_coordinate Author : Date : Return Desc. : Description : *********************************************************************/ void D_R_set_Actual_x_coordinate(robot_c * robot, unsigned int value) { set_pio_stepper_1_x(value) ; }
Another Example from ODMS • A hardware interrupt signals that the stepper motor deltas are all zero. • We would like to map this interrupt to the UML event; ‘Robot Move Complete’.
PIO.ifc .include “ARCH.ifc” .// .function FieldAsAttribute .param frag_ref Field .param frag_ref Attr .param frag_ref NavSpec .// Body Elided .end function .// .// .function VectoredInterruptAsEvent .param frag_ref Interrupt .param frag_ref Event .param frag_ref NavSpec .// Body Elided .end function
ODMS.PIO.brg .include “ARCH.ifc” .include “ODMS.pei” .include “PIO.ifc” .// .// Locate Client Domain Objects .invoke clDom = get_domain(“ODMS”) .invoke robot = get_object(clDom, “Robot”) .invoke robot_done = get_event(robot, “Robot Done”) .// .// Create Pre-existing Instances .invoke robot1 = createrobot() .invoke robotHW = createinterrupt(“0x0F7”) .invoke intReg = createregister(“Data5”, “0xFFF9”, 16, “IO”) .invoke intVecFld = createField(intReg, “Interrupt Vector”, 16, 0, FALSE, “RO”) .invoke regZero = createvector(robot_HW, intVecFld, “Registers Zero”) .// .// Map interrupt ‘Registers Zero’ onto ‘Robot Done’ .invoke NavSpec = createnavigationSpecification() .invoke idr = PreExstCtptObj(“IntF7 to Robot”, robot1, robotHW) .invoke createinterDomainReference(NavSpec, idr) .invoke VectoredInterruptAsEvent(regZero, robot_done, nullNavSpec)
Unmapped Impedance Matching Code /******************************************************************** Function name : Vector::Registers Zero Author : MC-2020 PIO Impedance Matcher Date : April 26 2001 Description : Interrupt Handler for Registers Zero *********************************************************************/ static void Vector::Registers_Zero(void) { /* No Mapping */ }
Mapped Impedance Matching Code /******************************************************************** Function name : Vector::Registers_Zero Author : MC-2020 PIO Impedance Matcher (PIOImpMatch.arc) Date : April 26 2001 Description : Interrupt Handler for Registers Zero *********************************************************************/ static void Vector::Registers_Zero(void) { // GENERATE R_5:‘robot done'() TO robot PTC_BPAL_STMT_TRACE( 1, "GENERATE R_5:‘robot_done'() TO robot" ) odms_R_Event5_c * event1 = new odms_R_Event5_c(IntF7_to_Robot_idr); event1->Send( odms_PIO_V_OBJECT_ID, pio_interdom_event_priority ); }
Process • The domain interface is provided by the Service Domain Analysts. • The interface elements are selected by the Client Domain Designers. • The selected interface elements are invoked in the .brg file to create required instances in the Bridging Metamodel. • To port or reuse, the .brg files are discarded.
And Finally . . . • Using Implicit Bridging concentrates coupling in the Bridge where it belongs. • There is NO coupling in the models. • Bridge and Interface files allow Domain information hiding. • This technology has now moved from theory to practise.
SMUG 2001Execution in UML May 7-9, 2001 Westward Look Resort Tucson, Arizona