An Introduction To UML:Unified Modeling Language
Chris RoederJune 2011
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
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
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)
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)
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)
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
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
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
Visibility
• Characters used to show visibility
• + public
• - private
• # protected
• ~ package
• _ static
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
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
Sequence Diagram 2
• Conditional
– [condition]
– Opt
– Alt
• Repeated
– *
– loop
Examples
• CCP UIMA type system
• CCP fileparsers project
• EntityTaggers from Code Review
• CCP NLP Shims
– Used to reverse engineer
Links
• http://en.wikipedia.org/wiki/Unified_Modeling_Language
• http://www.tracemodeler.com/articles/a_quick_introduction_to_uml_sequence_diagrams/
Top Related