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

Similar documents
Unified Modeling Language (UML) Class Diagram

Introduction to UML. Danang Wahyu utomo

Basic Structural Modeling. Copyright Joey Paquet,

Object-Oriented Systems Analysis and Design Using UML

LABORATORY 1 REVISION

Unified Modeling Language (UML)

UML Tutorial. Unified Modeling Language UML Tutorial

Architecture and the UML

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

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

CS487 Midterm Exam Summer 2005

Introducing the UML Eng. Mohammed T. Abo Alroos

Practical UML - A Hands-On Introduction for Developers

Design and UML Class Diagrams

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

UML Component Diagrams A.Y 2018/2019

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

Inheritance and Polymorphism

Software Engineering Lab Manual

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

UML Primer. -Elango Sundaram

Practical UML : A Hands-On Introduction for Developers

Polymorphism: Inheritance Interfaces

An Introduction To Object Modeling System Concept for Object Modeling The Overall View Components of UML Diagram

Object-Oriented Design and Modeling Using the UML

Allenhouse Institute of Technology (UPTU Code : 505) OOT Notes By Hammad Lari for B.Tech CSE V th Sem

Introduction to Software Engineering. 5. Modeling Objects and Classes

CHAPTER 9 DESIGN ENGINEERING. Overview

Object Oriented Modeling

CS 370 REVIEW: UML Diagrams D R. M I C H A E L J. R E A L E F A L L

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

UML Views of a System

Unit Wise Questions. Unit-1 Concepts

Design of Embedded Systems

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

Chapter 5: Structural Modeling

Object-Oriented and Classical Software Engineering

UML. By Somenath Mukhopadhyay.

Notation Part 1. Object Orientated Analysis and Design. Benjamin Kenwright

How and Why to Use the Unified Modeling Language. among software components, architectural-based

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

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

1. Introduction to Object Oriented Software Development

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

CS211 Lecture: Modeling Dynamic Behaviors of Systems; Interaction Diagrams in UML

Unified Modeling Language (UML)

Suggested answers are provided below. These answers are presented top-down, left to right.

Unified Modeling Language

SOFTWARE DESIGN COSC 4353 / Dr. Raj Singh

Unified Modeling Language (UML)

Ans 1-j)True, these diagrams show a set of classes, interfaces and collaborations and their relationships.

Oral Questions. Unit-1 Concepts. Oral Question/Assignment/Gate Question with Answer

Software Development Cycle. Unified Modeling Language. Unified Modeling Language. Unified Modeling Language. Unified Modeling Language.

Object-Oriented Systems Development: Using the Unified Modeling Language

Chapter 2 Entity-Relationship Data Modeling: Tools and Techniques. Fundamentals, Design, and Implementation, 9/e

Computer Science for Engineers

IS 0020 Program Design and Software Tools

Unit-1 INTRODUCTION 1.1 CATEGORIES OF INFORMATION SYSTEMS SYLLABUS:

ITEC420: Software Engineering Lecture 3: Recap OO/UML Requirement Workflow

SE Assignment III. 1. List and explain primitive symbols used for constructing DFDs. Illustrate the use of these symbols with the help of an example.

UML Fundamental. OutLine. NetFusion Tech. Co., Ltd. Jack Lee. Use-case diagram Class diagram Sequence diagram

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

Vidyalankar. T.Y. Diploma : Sem. VI [IF/CM] Object Oriented Modeling and Design Prelim Question Paper Solution

Unified Modeling Language

OO-Design. Steven R. Bagley

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

Pertemuan 8. Object Oriented Modeling and Design

Object-Oriented Analysis and Design Using UML (OO-226)

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

Object Orientated Analysis and Design. Benjamin Kenwright

Design Engineering. Dr. Marouane Kessentini Department of Computer Science

Software Engineering with Objects and Components Open Issues and Course Summary

+ Public - Private # Protected # Protected (Overridable) Static

Unified Modeling Language (UML) and Modeling

CS 200 More Classes Jim Williams, PhD

Introduction to UML Dr. Rajivkumar S. Mente

History of object-oriented approaches

Introduction to UML What is UML? Motivations for UML Types of UML diagrams UML syntax Descriptions of the various diagram types Rational Rose (IBM.. M

Chapter 2: The Object-Oriented Design Process

Final Exam. Final Exam Review. Ch 1: Introduction: Object-oriented analysis, design, implementation. Exam Format

SEEM4570 System Design and Implementation. Lecture 11 From Design to Implementation

Software Service Engineering

Agile Model-Driven Development with UML 2.0 SCOTT W. AM BLER. Foreword by Randy Miller UNIFIED 1420 MODELING LANGUAGE. gile 1.

Appendix A - Glossary(of OO software term s)

University of Calgary Department of Electrical and Computer Engineering. SENG : Object Oriented Analysis and Design Behrouz Homayoun Far

Chapter 12 Object-Oriented Programming. Starting Out with Games & Graphics in C++ Tony Gaddis

OO Techniques & UML Class Diagrams

UML: Unified Modeling Language

Using High-Level Conceptual Data Models for Database Design A Sample Database Application Entity Types, Entity Sets, Attributes, and Keys

Analysis and Design with UML

Architectural Blueprint

Lecture 17: (Architecture V)

Examples. Object Orientated Analysis and Design. Benjamin Kenwright

Solved Question Paper June 2017

Chapter 2 Entity-Relationship Data Modeling: Tools and Techniques. Fundamentals, Design, and Implementation, 9/e

Object-oriented design. More UML

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

What are the characteristics of Object Oriented programming language?

Experiment no 4 Study of Class Diagram in Rational Rose

Structured and Object Oriented Analysis and Design

Transcription:

UML UNIFIED MODELLING LANGUAGE EXEMPLIFIED ON BLACKJACK 1

Theoretically, before we write object-oriented code for solving a problem, we need to design an abstract model which depicts the essential features and hides all irrelevant details This is usually achieved by a bunch of Class Diagrams, Use-case diagrams, object diagrams, etc. The standard framework for doing it is called UML : Unified Modeling Language This framework deserves a full course of its own, but in this presentation we will exhibit some of its main ideas, exemplified on our Blackjack project 2

UML has nine kinds of modeling diagrams: Use-case diagrams Class diagrams Object diagrams Sequence diagrams Collaboration diagrams State-chart diagrams Activity diagrams Component diagrams Deployment diagrams The relation of UML to OOP is like architect to builder One must have a clear architectural plan before constructing a physical building! The plan should enable easy communication between both! 3

As of today, UML has become the standard modelling language for software analysts, architects, and programmers It enables managers, clients, and programmers (in one or several teams) to communicate efficiently when designing or refactoring software systems, even if some of the participants are not professional programmers UML is best tuned to object-oriented methodologies, therefore some familiarity with OOP is required before learning UML A UML model is an abstract system which represents the objects and the relations in our problem domain A UML model consist of abstract items ( objects ) that own attributes and methods UML objects can interact with each other by activating each other (one object can ask another object to invoke one of his method, or simply getting one of his attributes) 4

A class is the architectural plan for objects of its kind A class consists of attributes (or data members) and behaviors (also called methods) Objects are also knows as instances of a class Each object of a class, contains a private set of all the attributes, which forms its state (the values of these attributes may change a lot during the object lifetime) The class is a static entity that is always there, while its objects may come and go (construct/destruct) during the program life Classes are related by several types of association such as inheritance, composition, and other kinds of reference of one class by another 5

One way to describe what a system does is to list many of its usage scenarios A scenario is an example of how someone is using the system (actor) Create a new Deck of cards These are 4 Different use cases Create a Dealer Simulate 300 Games Create 3 Players 6

Collect system requirements The more use cases we have the more we know what are our system requirements Use cases are great source for regression tests Almost every use case can serve as a basis for one or more regression tests Communication Use cases are a great basis for discussions and brainstorming, between managers, tool architects, clients, developers, testers, and company accountants 7

Should display all the system classes and their relations 8

Every class in the system is represented by a box with three parts: Class name Data members Methods Names of abstract classes are in italics (Person) A relation between two classes is designated by a connecting line with (normal or dashed), a special arrow, and labels (adornments) 9

Association An association is a link connecting two classes Indicates that (at least) one of the two related classes makes reference to the other class One class is using the other class in order to perform its work Aggregation A special type of association Aggregation means that one class is contained as a member (or element) in the other class The first class is called a member (or element) and the other class is called a Container Examples: In blackjack, a Card is an element of Deck A Player object is an element of a Game object List is a container of its members 10

Composition A stronger type of aggregation in which the element is an essential part of the container (in such case the term component is used) Usually a data member that persist thru all the life cycle of the container In Blackjack, a Hand object is a strong component of a Player object The string object Player.name is an essential part of Player Any data member in a class is a component of that class A Blackjack Card object is not a strong component of a Deck object, since at any time it can be removed from the Deck and move to a Player Hand Generalization The classical is-a relationship (inheritance) in which one class is a superclass of the other In Blackjack, the Dealer class is a superclass of the Player class This is more a relation between classes (than their objects) An object of the second class is also an object of the first class! 11

Association Types Bidirectional Association Unidirectional Association Aggregation Element/Container relationship Generalization Element/Container relationship Generalization Element/Container relationship 12

http://www2.cs.uidaho.edu/~jeffery/courses/383/lecture.html All Associations in this diagram are of type Generalization (inheritance) Note that Circle and Rectangle classes have both a getarea method (polymorphism), but clearly Rectangle.getArea() is completely different than Circle.getArea() (method override) 13

http://shikhaandroid.files.wordpress.com/2012/07/class-diagram.png In this diagram we have three types of associations Unidirectional Association Composition Aggregation Note that some association lines have two arrows! 14

Blackjack Class Diagram (suggestion 0.1) Game dealer players log open() close() run() history() is_finished() 1 log string 1 2..6 1 state Dealer name budget hand state strategy deck shuffle() Player name budget hand state strategy hit() stand() 1 0..1 Deck cards shuffle() draw_card() Hand cards soft add(card) value() 0..52 0..52 Card rank suit value() 15

UML association line may contain An optional arrowhead that specifies the association type Optional label at each end of line which specifies the multiplicity of instances of that entity (the potential number of objects that may exist in the association) At each end of the line, we can add a short label ( adornment ) which details the kind of association Multiplicity 5 0..1 i..j i..* 0..* Meaning Five instances None or One instance i to j instances i or more instances (no upper limit) Any number of instances (including none) 16

Class Dependency Game 1 Dealer Player 0..1 Hand Game 2..6 Player Deck 0..52 Card Hand 0..52 Card Game string Player string 1 1 17

A class A is dependent on class B, if A is using B in one of the above relationships Practically, it means that class B must be implemented first, before A can do any work at all Dependency relations are extremely important (particularly for managers) in order to have a tidy work plan In real life projects, classes are usually developed by several developers, and class dependency is crucial for planning work timelines 18

While class diagram depicts a static view of our system, a sequence diagram is a dynamic view of the system in action A sequence diagram models a control flow scenario of the system arranged in a time sequence Time flows from top to bottom The objects involved in the scenario appear from left to right according to when they take part in the message sequence It consists of several objects that interact with each other within part or full life cycle (birth and death of objects) Sequence diagrams are associated with use case realization within the UML model of the system under development. Sequence diagrams are sometimes called event diagrams, event scenarios 19

object eli: Dealer object alice: Player object bob: Player object clod: Player object g1: Game run() draw_card() open() draw_card() alice.hand=hand() draw_card() draw_card() bob.hand=hand() draw_card() draw_card() Clod.hand=Hand() draw_card() draw_card() Hand() deal(alice) deal(bob) deal(clod) No more space 20

http://edn.embarcadero.com/article/31863 http://en.wikipedia.org/wiki/class_diagram http://en.wikipedia.org/wiki/unified_modeling_language http://en.wikipedia.org/wiki/list_of_uml_tools 21