UML Class Diagrams: Understanding Object-Oriented Programming II with Java - Prof. Nelson , Study notes of Computer Science

An overview of uml (unified modeling language) class diagrams, focusing on java programming. It explains the different types of relationships between classes, such as association, dependency, and generalization, and their notation. It also covers the concept of multiplicity and its notation. Examples of uml class diagrams for various systems, such as veterinary, computer, banking, and home heating systems, and provides instructions on how to derive java code from uml class diagrams and vice versa.

Typology: Study notes

Pre 2010

Uploaded on 07/30/2009

koofers-user-j2o
koofers-user-j2o 🇺🇸

9 documents

1 / 37

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CMSC 132:
Object-Oriented Programming II
Nelson Padua-Perez
William Pugh
Department of Computer Science
University of Maryland, College Park
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25

Partial preview of the text

Download UML Class Diagrams: Understanding Object-Oriented Programming II with Java - Prof. Nelson and more Study notes Computer Science in PDF only on Docsity!

CMSC 132:

Object-Oriented Programming II

Nelson Padua-Perez

William Pugh

Department of Computer Science

University of Maryland, College Park

UML Class Diagrams

Represent the (static) structure of the system General

In Java

Name

Name

State

Variables

Behavior

Methods

Association

Denotes permanent, structural relationship State of class A contains class B Represented by solid line (arrowhead optional)

Car

and

Engine

classes know about each other

Associations w/ Navigation Information

Can indicate direction of relationship Represented by solid line with arrowhead

Gas Pedal

class knows about

Engine

class

Engine

class doesn’t know about

Gas Pedal class

Multiplicity of Associations

Some relationships may be quantified Multiplicity denotes how many objects thesource object can legitimately reference Notation

0, 1, or more

5 exactly

between 5 and 8, inclusive

5 or more

Multiplicity of Associations

Many-to-one

Bank has many ATMs, ATM knows only 1 bank

One-to-many

Inventory has many items, items know 1 inventory

Dependency

Caused by class methods Method in Class

A

temporarily “

uses a

” object

of type Class

B

Change in Class

B

may affect class

A

A uses object of class B

A

B

Dependency

Dependence may be caused by

Local variable Parameter Return value

Example

Class A {

Class B {

B

Foo(

B

x) {

B

y = new B();

return y;

Generalization

Denotes

inheritance

between classes

Can view as “

is-a

” relationship

Represented by line ending in (open) triangle

Laptop, Desktop, PDA inherit

state & behavior from Computers

Implementation

Denotes class

implements

Java interface

Represented by dotted line ending in (open)triangle

A implements interface B

A

«B»

UML Example – Veterinary System

Try to read & understand UML diagram

UML Example – Veterinary System

Try to read & understand UML diagram

1 or more Pets associated with 1 PetOwner

UML Example – Computer System

Try to read & understand UML diagram

1 CPU associated with 0 or more Controllers

1-4 DiskDrives associated with 1 SCSIController

SCSIController is a (specialized) Controller

UML Example – Banking System

Try to read & understand UML diagram