Uml

17

Click here to load reader

Transcript of Uml

Page 1: Uml

An Introduction To UML:Unified Modeling Language

Chris RoederJune 2011

Page 2: Uml

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

Page 3: Uml

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

Page 4: Uml

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)

Page 5: Uml

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)

Page 6: Uml

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)

Page 7: Uml

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

Page 8: Uml

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

Page 9: Uml
Page 10: Uml

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

Page 11: Uml

Visibility

• Characters used to show visibility

• + public

• - private

• # protected

• ~ package

• _ static

Page 12: Uml

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

Page 13: Uml

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

Page 14: Uml
Page 15: Uml

Sequence Diagram 2

• Conditional

– [condition]

– Opt

– Alt

• Repeated

– *

– loop

Page 16: Uml

Examples

• CCP UIMA type system

• CCP fileparsers project

• EntityTaggers from Code Review

• CCP NLP Shims

– Used to reverse engineer