2. Modeling UML is a graphical modeling language. Drawing pictures of code Helps to visualize high-level abstractions and collaborations Limits detail 2 Major classes of diagrams Static/Structural Dynamic/Behavioral Simplified version discussed here
3. History UML: Unified Modelling Language Roots in work of “The Three Amigos” form early 90’s Grady Booch: Rational Rose Ivar Jacobsen: OOSE at Ericson “yah-cob-son” James Rumbaugh: Object Modelling Technique at GE 1.0 out in 1997 ISO standard in 2005 2.0 in 2005 2.4 in Beta
4. Modeling is useful for: A high-level description of the project It does not contain code-level detail Makes it easier to see the forest without all the trees in the way A graphical presentation Works better with some minds It’s about drawing and using the diagrams Doing design Not about having the diagrams for their own sake No Shelfware (gets written, sits on the shelf)
5. Static/Structural Class Diagram Shows classes and their relationships, both inheritance and composition Object Diagram Shows instantiations of classes, objects, at a specific point in time Package Diagram Deployment Diagram (Others)
6. Dynamic/Behavioral Sequence Diagram Shows method calls between objects in sequence Use-Case Diagram Describes activities in terms of actors, goals and dependencies Activity Diagram (others)
7. Class Diagram A class is a box and three sections: Name Members Methods Three kinds of arrows radiate out: Inheritance: an arrow that points to the base class Aggregation: a line starting with a hollow diamond that ends at the contained class: weak, catalog containment Composition: a line starting with a filled diamond that ends at the contained class: stronger, includes lifecycle, physical containment
8. Aggregation and Containment Aggregation Weak Catalog Containment List<Item> Items’ lifetime may be independent of catalog Composition Strong A Car’s engine, tires, doors Lifetime’s are related: No car, no engine
9.
10. Multiplicity Add quantifiers to ends of aggregation and composition relationships 0..1 – optional 1 – must have one 0..* - zero or more instances 1..* - at least one instance Quantifiers can go on either or both ends of a relationship
12. Role Names Can add role names to relationships different name depending on perspective: A is B’s parent, B is A’s child A is B’s employer, B is A’s employee
13. Sequence Diagram Shows the interaction between objects Objects are listed across the top in a single row Interactions are labelled arrows between lines extending down from the objects Very useful for mapping out an interaction when learning or debugging a new codebase. Objects are instances of Classes in your Class Diagram Editor picks up methods from the Class Diagram Classes can be used in parameters and return types