Title: cs2340: UML and Class Diagrams
1cs2340 UML and Class Diagrams
2Unified Modeling Language
- Three Amigos Booch, Rumbaugh (OMT), Jacobson
(OOSE) - OMG Standard
- CASE Tool Support (Rational Rose)
- For this class Version 2.0
- OCL Formal Specifications
3Model and View Diagrams
Implementation View
Class Diagram Object Diagram
Composite Structure Diagrams
User View Use Case Diagrams
Structural View
Component Diagrams
Communication Diagram Collaboration Diagram State
Diagram Activity Diagram Timing Diagram
Deployment Diagram
Behavioral View
Environment View
4Why so many diagrams?
Different stakeholders
Different concerns
Why not just one blueprint for a skyscraper?
5Package Diagrams
- Show basic package structure
- represents packages or namespaces
- Each classname in a package must be unique
- Show dependencies between packages
- Something in a package uses something in another
package - Typically a class in one package calls methods in
another class.
6Packages
A dependency
ServerServer
A Fully-Qualified Name
A package
7Simple Package Diagram
Well-structured is acyclic
8Class Diagrams
- A class diagram shows
- Packages (sub-packages of our package diagram)
- Classes
- Attributes
- Methods
- Interfaces
- Collaborations
- Dependency, Generalization, Relationships
- A class diagram is a STATIC view of system
9Three Levels of Class Diagrams
- Conceptual (Domain) Model
- Analysis (Specification)
- Implementation
10Basic Class Diagrams
11Basic Class Diagrams
public protected - private package /
derived
Abstract abstract
constructor query update
Class Scope (static)
Formats for boxes Visibility Attribute_Name
MultiplicityType Initial_Value
property-string Visibility Method_Name
(Parameter_List) Return-List
property-string kind param_Name type
default value , where kind in,
out , inout and surround optional items
12Basic Class Diagrams
Superclass
Class with parts
Note
Assembly Class
Subclass
Composition (Aggregation) (part-of, has-a)
Association (relationship)
Inheritance (Generalization) (is-a, kind-of)
13Basic Class Diagram (Example)
14Basic Class Diagram (Example)
15Class Diagrams (Advanced)
Cardinality (Multiplicity) 1 0..1 0.. 1..
64 2..5 2,4,10
takes
0..
16Class Diagrams (Advanced)
Important Stereotypes ltltinterfacegtgt specify
collection of operations to specify
services ltlttypegtgt specify structure and
behavior (not implementation) ltltenumerationgtgt
specify discrete values ltltimplementationClassgtgt
helper class created in detail design
17Class Diagrams (Advanced)
Aggregation (independent object lifetime)
Composite (unique member, dependent)
Exception handling
Can have self-associations
ltltsendsgtgt
manager
manages
employee
implements
directionality
18Class Diagrams (Advanced)
19One Additional Class Box
Class with independent Runtime thread of
execution AKA Active Class
20From Domain to Analysis (Specification)
21From Analysis (Specification) to Implementation
Book
Author
-isbnstring -titlestring writtenby5 Author
-namestring
- writtenby OrderedCollection
22From Implementation to Code
Author
Smalltalk.Library defineClass Author
superclass Core.Object indexedType
none private false instanceVariableNames
'name writtenBy ' classInstanceVariableNames
'' imports '' category
'Library name aString name
String initialize writtenBy
OrderedCollection new
-namestring
- writtenby OrderedCollection
Book
-isbnstring -titlestring writtenby5 Author