Title: Introduction to Object-Oriented Design and the UML
1Introduction toObject-Oriented Designand the UML
2Object-Oriented Modeling
- UML Unified Modeling Language
- Emerging OO Modeling Standard
- What is depicted?
- System functionality
- Class details and static relationships
- Object interaction
- State transition within an object
3Modeling Techniques
- Use Cases/Use Case Diagrams
- Class Diagrams
- CRC Cards
- Interaction Diagrams
- State Diagrams
4ExampleUse Case Diagram
LIBRARY SYSTEM
Facilitate Borrow
Search for Book
Borrower
Librarian
Facilitate Return
5Class Diagramsand CRC Cards
- Class Diagrams similar to ER Diagrams but in
addition, it incorporates - methods, not just attributes for each entity
- inheritance
- Class-Responsibility-Collaboration Cards
- technique that depicts responsibilities of
classes with respect to other classes (hints on
both data and behavior details)
6ExampleInteraction Diagram
2 checkIfAvailable()
Borrow Screen
Book
1 checkIfDelinquent() 3 borrowBook()
4 setBorrower()
Borrower
7ExampleState Diagram (Book)
start
Reserved
Borrowed
New
Librarian activates book as available
Borrower returns book
Available
8Object-Oriented Design Models
- Static Model
- Class Diagrams
- Dynamic Model
- Use Cases, Interaction Diagrams, State Diagrams,
others
9OO Static Model
- Class Diagrams
- Relationships
- Association
- Aggregation/Composition
- Inheritance
- Attribute and Method names
10Classes in a Class Diagram
- Class name only Example
- With Details Example
Bank Account
Class Name
Bank Acct double balance deposit() withdraw()
Class Name attributes methods
11Relationships
- Inheritance (arrow)
- example between Secretary and Employee
- Composition/Aggregation (diamond)
- example between Car and Wheel
- Association (line)
- example between Borrower and Book
12Inheritance
Employee
public class Secretary extends Employee
Secretary
13Composition
Car
Wheel
4
w
public class Car Wheel w ...
public Car() w new Wheel4
...
14Association
Borrower
Book
0..3
0..1
currBorr
bk
public class Borrower Book bk
public Borrower() bk new Book3
public class Book Borrower currBorr
15OO Dynamic Model
- Goal Represent
- Object behavior
- Object interaction
- Traditional (relational) Dynamic Modeling
- Data Flow Diagrams (DFDs)
- Problem Processes separate from data
- Need modeling notation that highlight tight
relationship between data processes
16DFD Example(Inventory Management)
Accept and Post Delivery
Delivery info
Transaction
Item Master
17OO CounterpartObject Interaction
new (delivery info)
Encoder
Transaction
post (item count)
Item Master
18Interaction Diagrams
- Rectangles Classes/Objects
- Arrows Messages/Method Calls
- Labels on Arrows
- sequence number
- method name
- more details, when necessary (conditions,
parameters, types, return types)
19Interaction Diagram Borrow-Book Example
2 avail checkIfAvailable()boolean
Borrow Screen
bBook
1 delinq checkIfDelinquent()boolean 3!delinq
avail borrowBook(Book b)
4 setBorrower(r)
rBorrower
20Methods
- Interaction Diagrams suggest methods for classes
- consequence on detailed class diagram
- The label(s) of an arrow should be a method of
the class the arrow points to - Library System
- Borrower class should have at least two methods
(checkIfDelinquent and borrowBook)