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
- Hand-drawn and then scanned
3Agenda
- Class Diagrams
- Symbology
- Basic Modeling
- Intermediate Modeling
4Class Diagrams
- A class diagram shows
- Classes
- Attributes
- Methods
- Interfaces
- Collaborations
- Dependency, Generalization, Relationships
- A class diagram is a STATIC view of system
5Three Levels of Class Diagrams
- Conceptual (Domain) Model
- Analysis (Specification)
- Implementation
6Basic Class Diagrams
7Basic Class Diagrams
public protected - private package /
derived
Abstract abstract
constructor query update
Class Scope
Formats for boxes Visibility Attribute_Name
MultiplicityType Initial_Value Visibility
Method_Name (Parameter_List) Return-List Kind
param_Name type default value
where kind in, out , inout
8Basic Class Diagrams
Superclass
Class with parts
Note
Assembly Class
Subclass
Composition (Aggregation) (part-of, has-a)
Association (relationship)
Inheritance (Generalization) (is-a, kind-of)
9Basic Class Diagram (Example)
takes
10Basic Class Diagram (Example)
Person
name String - ssn String birthday
Date / age int
getName String query -calculateAge int
11Class Diagrams (Advanced)
Cardinality (Multiplicity) 1 0..1 0.. 1..
64 2..5 2,4,10
takes
0..
12Class 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
13Class Diagrams (Advanced)
Aggregation (independent object lifetime)
Composite (unique member, dependent)
Can have self-associations
Exception handling
ltltsendsgtgt
manager
manages
employee
directionality
14Class Diagrams (Advanced)
15From Domain to Analysis (Specification)
16From Analysis (Specification) to Implementation
Book
Author
isbnstring titlestring
written by
namestring
1..5
Book
Author
isbnstring titlestring writtenby5 Author
namestring
writtenby ListltBookgt
17From Implementation to Code
Author
public class Author protected
stdstring name stdlistltBookgt
writtenby public class Book protected
stdstring isbn stdstring title
Author writtenby5
namestring
writtenby ListltBookgt
Book
isbnstring titlestring writtenby5 Author
18Class 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
19Class Diagram Hints
- Organize similar classes into packages
- Beware of cyclical generalization
- Use associations where there are structural
relationships - Associations are NOT comm pipes!!!!!!!
- Start with Conceptual model, then refine details
thru specification and implementation
20Design Digression
- Inheritance vs. Composition
- Information Hiding
- Delegation Design Pattern
- Inheritance vs. Attribute
- Attribute vs. Class
- Association Checklist (page 156)
- Class Identification (page 134)
- Domain analysis
- Nouns in requirements
- Data-driven vs. Responsibility-driven
- Proxy Classes
21Space Invader Class Diagram