Title: UML Class Diagrams
1UML Class Diagrams
2Miscellaneous
- Drawing Software
- Dia
- Visio, Argo, Poseidon
- Rational Rose
- From csh in Baird cluster type
- source /usr/local/rational/rs_setup.csh
- Rose
- QSEE SuperLite
- Omondo (http//www.omondo.com/)
- Hand-drawn and then scanned
3Agenda
- Package Diagrams
- Class Diagrams
- Symbology
- Basic Modeling
- Intermediate Modeling
4Package 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.
5Packages
A dependency
ServerServer
A Fully-Qualified Name
A package
6Simple Package Diagram
Well-structured is acyclic
7A Package Diagram
8Lab 5 Package Diagram
9Class 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
10Three Levels of Class Diagrams
- Conceptual (Domain) Model
- Analysis (Specification)
- Implementation
11Basic Class Diagrams
12Basic 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 K
ind param_Name type default value
where kind in, out , inout
13Basic Class Diagrams
Superclass
Class with parts
Note
Assembly Class
Subclass
Composition (Aggregation) (part-of, has-a)
Association (relationship)
Inheritance (Generalization) (is-a, kind-of)
14Basic Class Diagram (Example)
takes
15Basic Class Diagram (Example)
Person
name String - ssn String birthday
Date / age int
getName String query -calculateAge int
16Class Diagrams (Advanced)
Cardinality (Multiplicity) 1 0..1 0.. 1..
64 2..5 2,4,10
takes
0..
17Class 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
ltltenumerationgtgt Status
Idle Working Error
Fundamental Attributes
readImage writeImage
Fundamental behavior
18Class Diagrams (Advanced)
Aggregation (independent object lifetime)
Composite (unique member, dependent)
Can have self-associations
Exception handling
ltltsendsgtgt
manager
manages
employee
directionality
19Class Diagrams (Advanced)
20From Domain to Analysis (Specification)
21From Analysis (Specification) to Implementation
Book
Author
-isbnstring -titlestring
written by
-namestring
1..5
Book
Author
-isbnstring -titlestring writtenby5 Author
-namestring
- writtenby ListltBookgt
22From Implementation to Code
Author
public class Author private String name
private List writtenby public class Book
private String isbn private String title
Author writtenby5
-namestring
- writtenby ListltBookgt
Book
-isbnstring -titlestring writtenby5 Author
23One Additional Class Box
Class with independent Runtime thread of execution
24Class Diagram Hints
- Provide abstraction of problem domain
- Embodies small set of well-defined
responsibilities - Clear separation between specification and
implementation - Understandable and simple
- Show only important properties
25Class Diagram Hints
- Organize similar classes into packages
- Beware of cyclical generalization/dependencies
- Use associations where there are structural
relationships - Associations are NOT comm pipes!!!!!!!
- Start with Conceptual model, then refine details
thru specification and implementation
26Design Digression
- Inheritance vs. Composition
- Information Hiding
- Delegation Design Pattern
- Inheritance vs. Attribute
- Attribute vs. Class
- Association Checklist (page 155)
- Class Identification (page 139)
- Domain analysis
- Nouns in requirements
- Data-driven vs. Responsibility-driven
- Proxy Classes
27Lab 5 Class Diagram