05b-Design2

05b-Design2 - Interaction diagrams Dynamic views of...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Interaction diagrams z Dynamic views of interacting objects – Starts by system event ( external message ) – Receiving object either handles alone, or passes message along ( internal messages ) z Links in diagrams indicate visibility between classes z Why bother diagramming? – Easier to change drawing than code – Get big picture – better design, code, system z Do together with class diagrams/specifications z 2 basic types: sequence and communication Sequence diagrams z Use for simpler interactions – sequence easily shown as top-to-bottom interactions Communication diagrams z Handy for more complicated interactions – show sequences by numbering the interactions Notation for interactions z Class vs. instance – – Sale – class name for static methods only – mySale:Sale – object name:type for other z Messages – shown along link line – Must number in communication diagram – Show parameters too (with optional types) z e.g., 2: cost:=price(amount:double) – And return values if not void z e.g., 1.1: items:=count():int z Iteration – use * and optional [iteration clause] – e.g., 3*: [i:=1…10]li:=item(i):LineItem More notation for interactions z Conditions – [condition:boolean] – e.g., 1:[new sale]create() Æ :POST ------------------------:Sale – See fig. 15.30 (p. 244) for mutually exclusive conditions z Use “stack” icon for multi-objects (collections) – Note: message may be to the collection object itself (e.g., a list), or to the individual elements if * z Show algorithms as notes (dog-ear symbol) – But only need if tricky or otherwise relevant Design principles z Not exactly “rules” – things to consider – Should lead to high quality designs z Easier to maintain, understand, reuse, and extend – e.g., expert, low coupling, high cohesion, do-it-myself z Note: Larman labels some as “patterns” – General Responsibility Assignment Software Patterns z Larman: assigning responsibilities = “desert island skill” z Also notes: “one person’s pattern is another’s primitive building block” – “Design patterns” usually are more specific
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 The expert principle z Assign responsibility to class that has the necessary information – i.e., the “information expert” z Avoids passing info between objects z Still have collaboration as objects help others – e.g., Sale knows about all LineItems , and
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

05b-Design2 - Interaction diagrams Dynamic views of...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online