+ All Categories
Home > Documents > A means of graphically displaying a complicated programs 18-Mar-16 UML Thanks to Dave Matuczek,...

A means of graphically displaying a complicated programs 18-Mar-16 UML Thanks to Dave Matuczek,...

Date post: 20-Jan-2018
Category:
Upload: stephen-bishop
View: 213 times
Download: 0 times
Share this document with a friend
Description:
Design Patterns 3 Design Patterns common programming strategies Design Patterns are best described by UML We will learn some simple patterns in class
15
A means of graphically displaying a complicated programs Mar 11, 2022 UML Thanks to Dave Matuczek, UPenn
Transcript

A means of graphically displaying a complicated programs

May 14, 2023

UML

Thanks to Dave Matuczek, UPenn

What is UML?

2

UML stands for Unified Modeling Language or Universal Modeling Language

UML uses graphics to show the relationships between program classes and objects.

Design Patterns

3

Design Patterns common programming strategies

Design Patterns are best described by UMLWe will learn some simple patterns in class

Classes

4

A class is drawn as a rectangle with three sections

Name of the class

Variables

Methods

Variables

5

A variable is written as: domain name : typewhere:+ means public - means private

Example: +length:int

Variables

6

Static variables are underlinedAn initial value can be shown with =valueExample:

-numberOfEmployees:int=10

means numberOfEmployees is:privatestaticintegerand has 10 as its initial value

Methods

7

Methods are written as: domain name (parameters) : returnTypewhereDomain uses the same syntax variables (+, -,

blank)parameters are given as name:typeif the returnType is void, it is omittedconstructors are preceded by «constructor»interfaces are preceded by «interface»

Example of a class

8

Card

+cardId:int-copy:boolean=false

«constructor» Card( int id )+isKind( desiredKind:int )+isSharable( ):boolean+toString( ):String

Types of relationships

9

A

B

class Bextendsclass A

C

D1..4

“Is a” “Has a”

Class Ccontains

1 to 4 objectsof class D

IGeometry

Cube

Implements

Example: Geometry program

10

Dependency"uses "No instantiation OBJECT

new BankClass( );

Composition"has a"object instantiation

public BankAccountClass myAccount;myAccount = new

BankAccountClass( ….

Inheritance“is a”

public class Clock extends JFrame

Realizationinterface implementation

public class BankAccountClass implements IBankAccountClass

Association "knows a" object is passedpublic BankAccountClass( double money, int acct, PeopleClass

person ) { balance = money; accountNumber = acct; member = person;}


Recommended