Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Class Models
Essentials of class diagrams More sophisticated associations Reading: Chapter 4 of M. Page-Jones(2000) Fundamentals of Object-Oriented Design in UML. Chapters 5 and 6 of P. Stevens (2000) Using UML: Software engineering with objects and components.
Overview of UML.
classes
To check understanding of the domain To check coupling in the system
Overview of UML.
OO design
Scenario walk-through
Problem statement
Rough classes
CRC Cards
Overview of UML.
Cards are classes Responsibilities are operations (Some) attributes are associations Associations have to be worked out
Overview of UML.
Overview of UML.
Overview of UML.
Overview of UML.
Overview of UML.
Generalisation relationship
10
Overview of UML.
is a member of
11
Overview of UML.
Multiplicities
To specify amounts in associations Notation
Exact number Range of numbers (1..9) Arbitrary number (*) A combination of these separated by comma (3, 12..15, 901..*)
12
Overview of UML.
Multiplicities
1..*
13
Overview of UML.
is a member of
14
Overview of UML.
0..6
1 15 Overview of UML.
16
Overview of UML.
screened in
Row
contains
Screen
contains
reserves
19
Overview of UML.
Generalisation
inheritance
20
Overview of UML.
Book
contains
1..* availableCopy: Boolean ndAvailable: Copy borrowCopy: Boolean 1
is a member of
0..*
is a copy of
1..*
LibraryMember
1 borrowingLimit: integer
Copy
borrows
0..6 getAvailStatus: Boolean setAvailStatus: void
21
Overview of UML.
22
Overview of UML.
Aggregation
Programme
Course
23
Overview of UML.
Composition
24
Overview of UML.
Book
contains
1..* availableCopy: Boolean ndAvailable: Copy borrowCopy: Boolean 1
is a member of
0..*
is a copy of
1..*
LibraryMember
1 borrowingLimit: integer
Copy
borrows
0..6 getAvailStatus: Boolean setAvailStatus: void
25
Overview of UML.
Book
contains
1..* availableCopy: Boolean ndAvailable: Copy borrowCopy: Boolean
is a member of
1 is a copy of 1..*
LibraryMember
1 borrows borrowingLimit: integer 1..6
Copy
getAvailStatus: Boolean setAvailStatus: void
26
Overview of UML.
Roles
27
Overview of UML.
Navigability
Navigability
Library
1 validateMember: Boolean validateBook: Boolean borrowBook: Boolean 1 0..*
Book
contains
1..* availableCopy: Boolean ndAvailable: Copy borrowCopy: Boolean
is a member of
1 is a copy of 1..*
LibraryMember
1 borrows borrowingLimit: integer 1..6
Copy
getAvailStatus: Boolean setAvailStatus: void
29
Overview of UML.
Navigability
Library
1 validateMember: Boolean validateBook: Boolean borrowBook: Boolean 1 0..*
Book
contains
1..* availableCopy: Boolean borrowCopy:Copy returnCopy: Boolean
is a member of
1 is a copy of 1..*
LibraryMember
1 borrows borrowingLimit: integer 1..6
Copy
getAvailStatus: Boolean setAvailStatus: void
30
Overview of UML.
Qualified associations
33
Overview of UML.
Constraints
34
Overview of UML.
Association classes
35
Overview of UML.
parameters and return values. Note down the resulting signatures. Create outline classes with detailed field and method descriptions. Careful design is a key to successful implementation.
36
Overview of UML.
37
Overview of UML.
/** * This class implements a container which * represents a book of the library * * @author Pablo Romero * @version 2006.08.10 */ public class Book { // The title, its author, year of publication, // number of copies and the array of copies private String title; private String author; private int year; private int numberOfCopies; private ArrayList<Copy> Copies; /** * Create a new book * @param t the book's title * @param a the book's author * @param y the year of publication * @param n number of copies **/ public Book(String t, String a, int y, int n) { } } 38 Overview of UML.
/** * Veries whether there are available copies * of the book * @return true if there are available copies, * false otherwise */ public boolean availableCopy () { } /** * Finds an available copy of the book for a * member to borrow * @return an available copy of the book */ public Copy borrowCopy () { } /** * Returns a copy of the book * @return true if the copy is a valid copy * of the book, false otherwise */ public boolean returnCopy (Copy returnedCopy) { } Pablo Romero. Informatics Department
Summary
UML specifies restrictions on class
relationships through
multiplicities, generalisation, aggregation, composition, roles, navigability, qualified associations and constraints