Design and UML Class Diagrams

Similar documents
CSE 403: Software Engineering, Spring courses.cs.washington.edu/courses/cse403/15sp/ UML Class Diagrams. Emina Torlak

CSE 403 Lecture 8. UML Class Diagrams. Thanks to Marty Stepp, Michael Ernst, and other past instructors of CSE 403

design: specifying the structure of how a so9ware system will be wriqen and funclon, without actually wrilng the complete implementalon

2 UML for OOAD. 2.1 What is UML? 2.2 Classes in UML 2.3 Relations in UML 2.4 Static and Dynamic Design with UML. UML for OOAD Stefan Kluth 1

administrivia today UML start design patterns Tuesday, September 28, 2010

Agenda. Why Model. Why Model? History of OO Modeling Methodologies Object Modeling Technique (OMT) Unified Modeling Language (UML)

Introduction to Software Engineering. 5. Modeling Objects and Classes

Object-Oriented Software Engineering Practical Software Development using UML and Java

Object Oriented Modeling

Unified Modeling Language

UML Sequence Diagrams for Process Views

A - 1. CS 494 Object-Oriented Analysis & Design. UML Class Models. Overview. Class Model Perspectives (cont d) Developing Class Models

UML Modeling I. Instructor: Yongjie Zheng September 3, CS 490MT/5555 Software Methods and Tools

UML. By Somenath Mukhopadhyay.

CS1004: Intro to CS in Java, Spring 2005

Object-Oriented Software Engineering Practical Software Development using UML and Java. Chapter 5: Modelling with Classes

UML & OO FUNDAMENTALS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 3 08/30/2011

SOFTWARE DESIGN COSC 4353 / Dr. Raj Singh

CHAPTER 1. Topic: UML Overview. CHAPTER 1: Topic 1. Topic: UML Overview

Class diagrams. Modeling with UML Chapter 2, part 2. Class Diagrams: details. Class diagram for a simple watch

Software Service Engineering

OO System Models Static Views

Exercise Unit 2: Modeling Paradigms - RT-UML. UML: The Unified Modeling Language. Statecharts. RT-UML in AnyLogic

Object-Oriented Systems Analysis and Design Using UML

Chapter 2: The Object-Oriented Design Process

OO Analysis and Design with UML 2 and UP

Chapter 5: Structural Modeling

Business Process Modelling

UML UNIFIED MODELLING LANGUAGE EXEMPLIFIED ON BLACKJACK. Object Oriented Programming (Samy Zafrany)

UML: Unified Modeling Language

Chapter 10. Object-Oriented Analysis and Modeling Using the UML. McGraw-Hill/Irwin

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

CSE 403. UML Sequence Diagrams. Reading: UML Distilled Ch. 4, by M. Fowler

COSC 3351 Software Design. An Introduction to UML (I)

Model Driven Development Unified Modeling Language (UML)

Introduction to Software Engineering. 5. Modeling Objects and Classes

Software Engineering Lab Manual

Object Oriented Design. Program Design. Analysis Phase. Part 2. Analysis Design Implementation. Functional Specification

Unified Modeling Language (UML) Class Diagram

MSO Analysis & UML. Hans Philippi (based on the course slides of Wouter Swierstra) August 24, Analysis & UML 1 / 56

Class Diagram For Ticket Vending Machine Slibforme

22/09/2012 INFO2110. Copyright Warning. Revision of class diagram. Overview. Purpose of class diagram. Generalization Relationship

Design Engineering. Dr. Marouane Kessentini Department of Computer Science

Practical UML - A Hands-On Introduction for Developers

OO Techniques & UML Class Diagrams

Object-Oriented and Classical Software Engineering

UML Tutorial. Unified Modeling Language UML Tutorial

Introduction. Chapter 1. What Is Visual Modeling? The Triangle for Success. The Role of Notation. History of the UML. The Role of Process

PRINCIPLES OF SOFTWARE BIM209DESIGN AND DEVELOPMENT 00. WELCOME TO OBJECTVILLE. Speaking the Language of OO

Review: Cohesion and Coupling, Mutable, Inheritance Screen Layouts. Object-Oriented Design CRC Cards - UML class diagrams

SEEM4570 System Design and Implementation Lecture 11 UML

Practical UML : A Hands-On Introduction for Developers

Unified Modeling Language (UML)

Engineering Design w/embedded Systems

UML Primer. -Elango Sundaram

Course "Softwaretechnik" Book Chapter 2 Modeling with UML

Object-Oriented Systems Development: Using the Unified Modeling Language

Software Engineering from a

Unified Modeling Language (UML)

MechEng SE3 Lecture 7 Domain Modelling

Class diagrams. Modeling with UML Chapter 2, part 2. Class Diagrams: details. Class diagram for a simple watch

UML & OO Fundamentals. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 3 09/04/2012

Introducing the UML Eng. Mohammed T. Abo Alroos

Lesson 11. W.C.Udwela Department of Mathematics & Computer Science

Software Development. Modular Design and Algorithm Analysis

Basic Structural Modeling. Copyright Joey Paquet,

02291: System Integration

Modeling with UML. (1) Use Case Diagram. (2) Class Diagram. (3) Interaction Diagram. (4) State Diagram

Software Engineering

S T R U C T U R A L M O D E L I N G ( M O D E L I N G A S Y S T E M ' S L O G I C A L S T R U C T U R E U S I N G C L A S S E S A N D C L A S S D I A

Class Diagram. Classes consist of. Note that class diagrams contain only classes, not objects.

UML Is Not a Methodology

MSc programme (induction week) Department of Informatics INTRODUCTION TO UML

Modelling with Classes. CITS1220 Software Engineering

12 Tutorial on UML. TIMe TIMe Electronic Textbook

Inheritance and Polymorphism

Class Diagram. Classes consist of. Note that class diagrams contain only classes, not objects.

1/17/2014. UML Help and Details (from: UML for cse UML for a class. UML and project clarifications

INTRODUCTION TO UNIFIED MODELING MODEL (UML) & DFD. Slides by: Shree Jaswal

CISC 322 Software Architecture

Chapter 12. UML and Patterns. Copyright 2008 Pearson Addison-Wesley. All rights reserved

UML Component Diagrams A.Y 2018/2019

Chapter No. 2 Class modeling CO:-Sketch Class,object models using fundamental relationships Contents 2.1 Object and Class Concepts (12M) Objects,

Introduction to UML. Danang Wahyu utomo

Object-Oriented Design. Chapter. Class Relationships. Classes in a software system can have various types of relationships to each other

Lecture 33 April 4, Unied Modelling Language. ECE155: Engineering Design with Embedded Systems Winter Patrick Lam version 1

Polymorphism: Inheritance Interfaces

UML (Unified Modeling Language)

Chapter 2, Modeling with UML, Part 2

Meltem Özturan

CSCI 253. Outline. Rationale. George Blankenship 1. Object Oriented Design: UML. George Blankenship

Structural specification

CS 451 Software Engineering

Dr.S.S.Riaz Ahamed Principal, Sathak Institute of Technology, Ramanathapuram,India.

1 Reference Material for these slides is taken from many UML reference books. However, the two I most often used are: UML Explained, by Kendall Scott,

02291: System Integration

Äriprotsesside modelleerimine ja automatiseerimine Loeng 7 Valdkonna mudel

Object Oriented Software Development CIS Today: Object Oriented Analysis

Today s Topic. Lecture 5. What is UML? Why Use UML. UML Diagrams. Introduction to UML. What is UML Why use UML? UML Diagrams

Unified Modeling Language (UML)

Transcription:

Design and UML Class Diagrams 1 Suggested reading: Practical UML: A hands on introduction for developers http://dn.codegear.com/article/31863 UML DistilledCh. 3, by M. Fowler

How do people draw / write down software architectures?

Example architectures person sea agent VerizonWireless UW student lake agent GPS satellite CSE 403 student amphibious agent Cell phone

Big questions What is UML? Why should I bother? Do people really use UML? What is a UML class diagram? What kind of information goes into it? How do I create it? When should I create it?

Design phase design: specifying the structure of how a software system will be written and function, without actually writing the complete implementation a transition from "what" the system must do, to "how" the system will do it What classes will we need to implement a system that meets our requirements? What fields and methods will each class have? How will the classes interact with each other?

How do we design classes? class identification from project spec / requirements nouns are potential classes, objects, fields verbs are potential methods or responsibilities of a class CRC card exercises write down classes' names on index cards next to each class, list the following: responsibilities: problems to be solved; short verb phrases collaborators: other classes that are sent messages by this class (asymmetric) UML diagrams class diagrams (today) sequence diagrams...

What is UML? UML: pictures of an OO system programming languages are not abstract enough for OO design UML is an open standard; lots of companies use it What is legal UML? a descriptivelanguage: rigid formal syntax (like programming) a prescriptive language: shaped by usage and convention it's okay to omit things from UML diagrams if they aren't needed by team/supervisor/instructor

Uses for UML as a sketch: to communicate aspects of system forward design: doing UML before coding backward design: doing UML after coding as documentation often done on whiteboard or paper used to get rough selective ideas as a blueprint: a complete design to be implemented sometimes done with CASE (Computer-Aided Software Engineering) tools as a programming language: with the right tools, code can be auto-generated and executed from UML only good if this is faster than coding in a "real" language

UML In an effort to promote Object Oriented designs, three leading object oriented programming researchers joined ranks to combine their languages: Grady Booch (BOOCH) Jim Rumbaugh (OML: object modeling technique) Ivar Jacobsen (OOSE: object oriented software eng) and come up with an industry standard [mid 1990 s].

UML Unified Modeling Language Union of all Modeling Languages Use case diagrams Class diagrams Object diagrams Sequence diagrams Collaboration diagrams Statechart diagrams Activity diagrams Component diagrams Deployment diagrams. Very big, but a nice standard that has been embraced by the industry.

Object diagram ( class diagram) individual objects (heap layout) objectname: type attribute = value lines show field references Class diagram: summary of all possible object diagrams

Object diagram example

UML class diagrams UML class diagram: a picture of the classes in an OO system their fields and methods connections between the classes that interact or inherit from each other Notrepresented in a UML class diagram: details of how the classes interact with each other algorithmic details; how a particular behavior is implemented

Diagram of one class class name in top of box write <<interface>> on top of interfaces' names use italics for an abstract class name attributes (optional) includes fields of the object operations / methods (optional) may omit trivial (get/set) methods but don't omit any methods from an interface! should not include inherited methods

Class attributes (= fields) attributes (fields, instance variables) visibility name: type[count] = default_value visibility: + public # protected - private ~ package (default) / derived underline static attributes derived attribute: not stored, but can be computed from other attribute values specification fields from CSE 331 attribute example: -balance : double = 0.00

Class operations / methods operations / methods visibility name(parameters) : return_type visibility: + public # protected - private ~ package (default) underline static methods parameter types listed as (name: type) omit return_type on constructors and when return type is void method example: + distance(p1: Point, p2: Point): double

Comments represented as a folded note, attached to the appropriate class/method/etc by a dashed line

Relationships between classes generalization: an inheritance relationship inheritance between classes interface implementation association: a usage relationship dependency aggregation composition

Generalization (inheritance) relationships hierarchies drawn top-down arrows point upward to parent line/arrow styles indicate whether parent is a(n): class: solid line, black arrow abstract class: solid line, white arrow interface: dashed line, white arrow often omit trivial / obvious generalization relationships, such as drawing the Object class as a parent

Associational relationships associational (usage) relationships 1. multiplicity (how many are used) * 0, 1, or more 1 1 exactly 2..4 between 2 and 4, inclusive 3..* 3 or more (also written as 3.. ) 2. name (what relationship the objects have) 3. navigability (direction)

Multiplicity of associations one-to-one each student must carry exactly one ID card one-to-many one rectangle list can contain many rectangles

Association types aggregation: is part of symbolized by a clear white diamond 1 1 Car Engine aggregation composition: is entirely made of stronger version of aggregation the parts live and die with the whole symbolized by a black diamond dependency: uses temporarily symbolized by dotted line often is an implementation detail, not an intrinsic part of that object's state Lottery Ticket composition dependency Book 1 * Page Random

Composition/aggregation example If the movie theater goes away so does the box office => composition but movies may still exist => aggregation

Class diagram example No arrows; info flows in both directions; each knows about the other Aggregation Order class contains OrderDetail classes. Could be composition?

UML example: people Let s add the visibility attributes

26 Class diagram: voters

Class diagram example: video store Multiplicity Class Customer 1 Simple Aggregation Abstract Rental Invoice Class Rental Item 1..* 1 0..1 Generalization Composition Simple Association DVD Movie VHS Movie Video Game Checkout Screen

Class diagram example: student StudentBody + main (args : String[]) Address - streetaddress : String - city : String - state : String - zipcode : long + tostring() : String 1 100 Student - firstname : String - lastname : String - homeaddress : Address - schooladdress : Address + tostring() : String

Tools for creating UML diagrams Violet (free) http://horstmann.com/violet/ Rational Rose http://www.rational.com/ Visual Paradigm UML Suite (trial) http://www.visual-paradigm.com/ (nearly) direct download link: http://www.visual-paradigm.com/vp/download.jsp?product=vpuml&edition=ce (there are many others, but most are commercial)

Design exercise: Texas Hold empoker game 2 to 8 human or computer players Each player has a name and stack of chips Computer players have a difficulty setting: easy, medium, hard Summary of each hand: Dealer collects ante from appropriate players, shuffles the deck, and deals each player a hand of 2 cards from the deck. A betting round occurs, followed by dealing 3 shared cards from the deck. As shared cards are dealt, more betting rounds occur, where each player can fold, check, or raise. At the end of a round, if more than one player is remaining, players' hands are compared, and the best hand wins the pot of all chips bet so far. What classes are in this system? What are their responsibilities? Which classes collaborate? Draw a class diagram for this system. Include relationships between classes (generalization and associational).

Class diagram pros/cons Class diagrams are great for: discovering related data and attributes getting a quick picture of the important entities in a system seeing whether you have too few/many classes seeing whether the relationships between objects are too complex, too many in number, simple enough, etc. spotting dependencies between one class/object and another Not so great for: discovering algorithmic (not data-driven) behavior finding the flow of steps for objects to solve a given problem understanding the app's overall control flow (event-driven? web-based? sequential? etc.)