1 / 14

STD Case Study: BDE’s Caption and Node Resize ops.

STD Case Study: BDE’s Caption and Node Resize ops. In UML2/MDA, state models are required to provide an exact specification of dynamic behavior for code generation. Here we apply this method to two BDE functions: (1) caption_resize in captionops.cc (2) node_resize in nodeops.cc.

lou
Download Presentation

STD Case Study: BDE’s Caption and Node Resize ops.

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. STD Case Study: BDE’s Caption and Node Resize ops. • In UML2/MDA, state models are required to provide an exact specification of dynamic behavior for code generation. • Here we apply this method to two BDE functions: (1) caption_resize in captionops.cc (2) node_resize in nodeops.cc. • Goals of this case study (TBD): (1) Extend node_resize to redraw non-rect. shapes. (2) Test and debug (this version of) the actual code. (3) Assess the value of code compaction macros to help bridge the semantic gap from diagrams to source code. (4) Apply lessons learned to compress other BDE methods into precise, complete and consistent STD specifications. (5) Assess whether these methods should be delegated to a shape component of a node or caption which can inherit from a shape superclass. resize_HNandCG_STD.ppt - Revised 041119

  2. Motivation for State Diagrams • The STD partitions event-driven source code into control state blocks. Control sequencing constraints are visualized as state transitions labeled by their causal event types and guard conditions. • These dependencies replace reliance on ad hoc flag variables whose cause/effect relationships are not consistent and much harder to trace. • Tracing actual code behavior requires consistency between text annotations on the STD and the source code’s equivalent guard conditions and actions. • One way to verify this consistency is to formally define macros or in-line functions for the desired guards and actions, to represent them compactly on the STD. • A pre-processor can then automate much of the process of translating STD textual content into executable and/or interpretable code. resize_HNandCG_STD.ppt - Revised 041119

  3. caption_resize STD notes (1):5 new states, 3 event abbrev’ns State SCR SCaptionResize was split into 3 states: • #define SCRBD SCaptionResizeButtonDown • #define SCRBMU0 SCaptionResizeButtonMoveUpG1 • #define SCRBMU1 SCaptionResizeButtonMoveUpG2 State SCCR SCaptionConfirmResize was split into 2 states: • #define SCCRBD SCaptionConfirmResizeButtonDown • #define SCCRBMU SCaptionConfirmResizeButtonMoveUp Button events were abbreviated: • #define BD BUTTON_DOWN_EVENT • #define BM BUTTON_MOVED_EVENT • #define BU BUTTON_UP_EVENT resize_HNandCG_STD.ppt - Revised 041119

  4. caption_resize STD notes (2):State-splitting to expose constraints • Caption_resize originally had only two states SCR and SCCR. These have been split into multiple states to make the event pattern (BU BM* BD) directly visible on the STD. • This regular expression (BD BM* BU) is a basic sequence of GUI event inputs which must occur at least twice to complete a BDE caption or node resize operation. • The *BMU* states handle 0 or more BM events as well as BU. SCRBMU0, SCRBMU1 have different guard conditions and cannot be merged due to non-equivalent actions and/or next-states. SCCRBMU0 was merged into SCRBMU0 because they were equivalent states (their ensuing histories were identical). resize_HNandCG_STD.ppt - Revised 041119

  5. caption_resize STD notes (3):symbol, guard and action abbrev’ns.* • #define cs currentselection • #define sc selected_caption • #define ccc changeCanvasCursor (to arrow or movehand) • #define csHasTypeCG (hasType((id=(hcg_key)cs->getid()),CG)) • #define select_CG ((cs=reselect(event, &x, &y)) && csHasTypeCG) // select_CG was SCRBUG1 The above compact forms are used in these Guard Conditions: • #define SCCRBDG1 (sc!=0 && cs==sc && csHasTypeCG) • #define SCCRBDG2 (sc!=0 && (cs==0 || !csHasTypeCG)) • #define SCCRBDG3 (sc!=0 && cs!=0 && cs!=sc && csHasTypeCG ) * These symbols compress the executable code to conserve space on the STD. Unfortunately, the predicates csHasTypeCG and reselect() used in guard expressions are NOT side-effect-free. This (bad) specification technique is not recommended in practice except for code translation purposes. I don’t know how best to avoid this notational conflict, although more detailed state-splitting can help. resize_HNandCG_STD.ppt - Revised 041119

  6. Action routines for caption-redraw states SCCRBD and SCCRBMU1 * • #define doSCCRbegin \ do_caption_resize_begin((int)event->x, (int)event->y) • #define doSCCRmove \ do_caption_resize_move((int)event->x, (int)event->y) • #define doSCCRend \ do_caption_resize_end((int)event->x, (int)event->y) * doSCCRbegin replaces event-case block SCCRBDA1. doSCCRend replaces event-case block SCCRBUA1. doSCCRmove = do_caption_resize_move was do_caption_resize in event case block SCCRBM. resize_HNandCG_STD.ppt - Revised 041119

  7. caption_resize STD BD&& (cs=select_CG) SCRBD SCRBMU1 BD && !(cs=select_CG) / sc=cs=0; BM / no-op BU BU / ccc(hand); sc=cs; BD&&(cs=select_CG) && (cs!=sc) / sc = cs; BD&&!(cs=select_CG) / ccc(arrow); sc=cs=0; SCRBMU0 SCCRBD BM / no-op BD&&(cs=select_CG) &&(cs==sc) / doSCCRbegin BU / doSCCRend SCCRBMU1 BM / doSCCRmove resize_HNandCG_STD.ppt - Revised 041119

  8. caption_resize STD BD&& (cs=select_CG) SCRBD SCRBMU1 BD && !(cs=select_CG) / sc=cs=0; BM / no-op BU BU / ccc(hand); sc=cs; BD&&(cs=select_CG) && (cs!=sc) / sc = cs; BD&&!(cs=select_CG) / ccc(arrow); sc=cs=0; SCRBMU0 SCCRBD BM / no-op BD&&(cs=select_CG) &&(cs==sc) / doSCCRbegin BU / doSCCRend This dashed line divides states to merge Into SCR (above) and SCCR (below). NOTE: select_CG alters cs and id; It returns non-null cs iff cs has type CG. It sets id to cs->getid for any valid cs-type. SCCRBMU1 BM / doSCCRmove resize_HNandCG_STD.ppt - Revised 041119

  9. caption_resize STD * * Suffixes partition the state names SCR and SCCR according to the subset of (guarded) button events they handle. BD&& (cs=select_CG)** SCRBD SCRBMUG1 BD && !(cs=select_CG)** / sc=cs=0; BM / no-op BU BU / ccc(hand); sc=cs; BD&&!(cs=select_CG)** / ccc(arrow); sc=cs=0; SCRBMUG2 BD&&(cs=select_CG)** && (cs!=sc) / sc = cs; SCCRBD BM / no-op BD&&(cs=select_CG)** &&(cs==sc) / doSCCRbegin BU / doSCCRend ** select_CG sets cs = reselect(event,sx,sy) and returns cs iff csHasTypeCG); otherwise select_CG returns 0 if cs is either 0 or a non-CG object pointer. select_CG also sets id = cs->getid(). SCCRBMU BM / doSCCRmove resize_HNandCG_STD.ppt - Revised 041119

  10. caption_resize STD BU/- BD&& (cs=select_CG)/- SCRBD SCRBMU01 BD && !(cs=select_CG) / sc=cs=0; BM / no-op BU / ccc(hand); sc=cs; BD&&!(cs=select_CG) / {ccc(arrow); sc=cs=0;} States SCRBMU) and SCRBM1 have been merged into SCRBMU01, but Event BU in state SCCR has non-deterministic transitions. Guards have not yet been added. BD&&(cs=select_CG) && (cs!=sc) / sc = cs; SCCRBD BD&&(cs=select_CG) &&(cs==sc) / doSCCRbegin BU / doSCCRend SCCRBMU1 BM / doSCCRmove resize_HNandCG_STD.ppt - Revised 041119

  11. caption_resize STD BU&&(! csHasTypeCG) //new id BD&& (cs=select_CG)**/ - SCRBD BD && !(cs=select_CG)** / sc=cs=0; SCRBMU01 Guards have been added to 2 BU TR’s out of SCRBMU01. TR’s on BU are now deterministic. Error: SCCRBD has no BM action if cs != sc. (TBD: Merge SCCRBMU1 and SCCRBD.) (See next slide) BU&&csHasTypeCG* / ccc(hand); sc=cs; //new id BM / no-op BD&&!(csHasTypeCG)* / {ccc(arrow); sc=cs=0;} BD&&(cs=select_CG) && (cs!=sc) / {sc = cs; cs = 0; } //TBD:Add BM/Action? SCCRBD BD&&(cs=select_CG)** &&(cs==sc) / doSCCRbegin //new cs and id BU / doSCCRend * [BU’s guard recomputes id but not cs: (csHasTypeCG is TRUE iff cs is non-null and type CD).] ** [select_CG updates both cs and id. Do not redo after BM).] SCCRBMU1 BM / doSCCRmove resize_HNandCG_STD.ppt - Revised 041119

  12. caption_resize STD BU&&(! csHasTypeCG) //new id BD&&(cs=select_CG) / - TBD: Merge SCRBD and SCRBMU01 SCRBD SCRBMU01 BD && !(cs=select_CG) / sc=cs=0;//new cs, id BM / no-op BU&&csHasTypeCG* / ccc(hand); sc=cs; //new id BD&&!(cs) / ccc(arrow); sc=cs=0; BD&&(cs=select_CG) && (cs!=sc) / no-op;*** BU&& (cs!=sc) / no-op; SCCRBD SCCRBMU1 has been merged into SCCRBD. This requires guards (sc==cs) on BM and BU actions. BU&&(cs==sc) / doSCCRend BD&&(cs=select_CG)&& (cs==sc) / doSCCRbegin BM&&(cs!=sc) /no-op; BM&&(cs==sc) / doSCCRmove *** Cannot do sc = cs now because BM action is now guarded with (sc==cs). resize_HNandCG_STD.ppt - Revised 041119

  13. caption_resize STD BU&&(! csHasTypeCG) BD&&(cs=select_CG) / - SCR BD &&!(cs=select_CG) / sc=cs=0; BM / no-op BU&&csHasTypeCG* / ccc(hand); sc=cs; BD&&!(cs=select_CG)* / ccc(arrow); sc=cs=0; BD&&(cs=select_CG) && (cs!=sc) / no-op; BU&& (cs!=sc) / no-op; SCCRBD BU&&(cs==sc) / doSCCRend BD&&(cs=select_CG)&& (cs==sc) / doSCCRbegin SCRBMU01 and SCRBD are now merged into SCR. This requires no more guards. BM&&(cs!=sc) /no-op; BM&&(cs==sc) / doSCCRmove resize_HNandCG_STD.ppt - Revised 041119

  14. resize_node STD SResize SResize_node1 SResize_node SResize_node2 resize_HNandCG_STD.ppt - Revised 041119

More Related