1 CSE 403 Design and UML Class Diagrams Reading: UML Distilled Ch. 3, by M. Fowler These lecture slides are copyright (C) Marty Stepp, 2007. They may not.

Slides:



Advertisements
Similar presentations
Georgia Institute of Technology Object-Oriented Analysis Barb Ericson June 2006.
Advertisements

UML Class and Sequence Diagrams Violet Slides adapted from Marty Stepp, CSE 403, Winter 2012 CSE 403 Spring 2012 Anton Osobov.
Problem Solving #1 ICS Outline Review of Key Topics Review of Key Topics Example Program Example Program –Problem 7.1 Problem Solving Tips Problem.
CSE 331 SOFTWARE DESIGN & IMPLEMENTATION UNIFIED MODELING LANGUAGE (UML) Autumn 2011
Inheritance. Extending Classes It’s possible to create a class by using another as a starting point  i.e. Start with the original class then add methods,
Design Patterns in Java Appendix D UML at a Glance Summary prepared by Kirk Scott 1.
What is UML? A modeling language standardized by the OMG (Object Management Group), and widely used in OO analysis and design A modeling language is a.
CSE 403 Lecture 7 UML Class Diagrams Reading:
1 TCSS 360, Spring 2005 Lecture Notes Design Phase and UML Class Diagrams Relevant Reading: UML Distilled, Third Edition M. Fowler.
UML January 24, 2011 CSE 403, Winter 2011, Brun Design and UML Class Diagrams.
Unified Modeling Language
The Unified Modeling Language (UML) Class Diagrams.
UML Sequence Diagrams Reading: UML Distilled Ch. 4, by M. Fowler
Sequence Diagram Tutorial
Introduction to UML Lian Yu Department of Computer Science and Engineering Arizona State University Tempe, AZ
CSE 1301 Lecture 11 Object Oriented Programming Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established.
CSE 1302 Lecture 7 Object Oriented Programming Review Richard Gesick.
1 Object Oriented Design and UML Class Relationships –Dependency –Aggregation –Inheritance Reading for this Lecture: L&L 6.4 – 6.5.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
CS3773 Software Engineering Lecture 04 UML Class Diagram.
Centre for Computer Technology ICT214 Object Oriented Design and Programming Week 02 – Classes, Objects, Instances Richard Salomon and Umesh Patel Centre.
1 Class Diagrams: Advanced Concepts. 2 Overview Class diagrams are the most commonly used diagrams in UML. Class diagrams are the most commonly used diagrams.
Introduction to Unified Modeling Language (UML) By Rick Mercer with help from The Unified Modeling Language User Guide, Grady Booch, James Rumbaugh, Ivar.
UML Class Diagrams 1 These lecture slides are copyright (C) Marty Stepp, They may not be rehosted, sold, or modified without expressed permission.
An Introduction to the Unified Modeling Language
1 Object Oriented Design and UML Class Relationships –Dependency –Aggregation –Interfaces –Inheritance Interfaces Reading for this Lecture: L&L 6.4 – 6.5.
UML The Unified Modeling Language A Practical Introduction Al-Ayham Saleh Aleppo University
Chapter 5 System Modeling Sommerville, "software engineering ", 9 th Ed., 2011.
Appendix D UML at a Glance Summary prepared by Kirk Scott 1.
Design Model Lecture p6 T120B pavasario sem.
CSE 403, Spring 2008, Alverson Using UML to express Software Architecture.
CSE 403, Spring 2007, Alverson Using UML to express Software Architecture.
Introduction to UML CS A470. What is UML? Unified Modeling Language –OMG Standard, Object Management Group –Based on work from Booch, Rumbaugh, Jacobson.
INFO 620Lecture #71 Information Systems Analysis and Design Design Class Diagrams and others INFO 620 Glenn Booker.
INFSY 535.  Small systems  Larger systems 1.Understand the program requirement- what 3. Write and test each part (unit testing) 4. Maintenance 2. Specify.
CSE 403 Lecture 8 UML Sequence Diagrams Reading: UML Distilled, Ch. 4, M. Fowler slides created by Marty Stepp
ITEC0724 Modern Related Technology on Mobile Devices Lecture Notes #2 1.
Class Diagrams Chapter 3. Classes and Objects Classes are the descriptions –definitions Objects are the things –instances.
Object Oriented Programming and Data Abstraction Earl Huff Rowan University.
Unified Modeling Language (UML)
25/2/16. Software Design (UML) ClassName attributes operations A class is a description of a set of objects that share the same attributes, Operations.
Introduction to Unified Modeling Language (UML) By Rick Mercer with help from The Unified Modeling Language User Guide, Grady Booch, James Rumbaugh, Ivar.
Inf 43: Introduction to Software Engineering May 7, 2016.
Design and UML Class Diagrams
TCSS 305 (Stepp) OO Design with UML Class Diagrams
Structural Modeling.
Unified Modeling Language
Object-Oriented Analysis and Design
Unified Modeling Language
UML UML Sequence Diagrams CSE 403
Introduction to Unified Modeling Language (UML)
Analysis and Design with UML: Discovering Classes and Relationships
Lecture on Design Phase and UML Class Diagrams
Object-Oriented Analysis
Analysis and Design with UML: Discovering Classes and Relationships
Object Oriented Programming
Introduction to Unified Modeling Language (UML)
Object Oriented Programming
Analysis and Design with UML: Discovering Classes and Relationships
Introduction to Unified Modeling Language (UML)
CIS 375 Bruce R. Maxim UM-Dearborn
Unified Modelling Language
Analysis and Design with UML: Classes and Relationships
Object Oriented Programming Review
Introduction to UML Sources:
CIS 375 Bruce R. Maxim UM-Dearborn
Object Oriented System Design Class Diagrams
From Class Diagram to Contract Diagram
Presentation transcript:

1 CSE 403 Design and UML Class Diagrams Reading: UML Distilled Ch. 3, by M. Fowler These lecture slides are copyright (C) Marty Stepp, They may not be rehosted, sold, or modified without expressed permission from the author. All rights reserved.

2 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?

3 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?

4 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...

5 Introduction to 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 descriptive language: 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

6 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

7 UML class diagrams What is a UML class diagram? What are some things that are not represented in a UML class diagram? details of how the classes interact with each other algorithmic details; how a particular behavior is implemented UML class diagram: a picture of the classes in an OO system, their fields and methods, and connections between the classes that interact or inherit from each other

8 Diagram of one class class name in top of box write > on top of interfaces' names use italics for an abstract class name attributes (optional) should include all 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

9 Class attributes 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 attribute example: - balance : double = 0.00

10 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

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

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

13 Generalization relationships generalization (inheritance) relationships hierarchies drawn top-down with arrows pointing upward to parent line/arrow styles differ, based on whether parent is a(n): class: solid line, black arrow abstract class: solid line, white arrow interface: dashed line, white arrow we often don't draw trivial / obvious generalization relationships, such as drawing the Object class as a parent

14 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 2. name (what relationship the objects have) 3. navigability (direction)

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

16 Association types aggregation: "is part of" symbolized by a clear white diamond 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 1 1 Car aggregation Engine Lottery Ticket Random dependency Page Book composition * 1

17 Class diagram example 1

18 Class diagram example 2 DVD MovieVHS MovieVideo Game Rental Item Rental Invoice 1..* 1 Customer Checkout Screen Simple Association Class Abstract Class Simple Aggregation Generalization Composition Multiplicity

19 Class diagram example 3 StudentBody + main (args : String[]) + toString() : String 1100 Student - firstName : String - lastName : String - homeAddress : Address - schoolAddress : Address + toString() : String - streetAddress : String - city : String - state : String - zipCode : long Address

20 Tools for creating UML diags. Violet (free) Rational Rose Visual Paradigm UML Suite (trial) (nearly) direct download link: (there are many others, but most are commercial)

21 Class design exercise Consider this Texas Hold 'em poker game system: 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).