CSI 32. Lecture Object-Oriented Paradigm. UML (Unified Modeling Language)

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

Object-Oriented Programming. Objects. Objects. Objects

SEEM4570 System Design and Implementation Lecture 11 UML

Object-Oriented Programming

Course "Softwaretechnik" Book Chapter 2 Modeling with UML

SEEM4570 System Design and Implementation. Lecture 10 UML

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

Credit where Credit is Due. Lecture 4: Fundamentals of Object Technology. Goals for this Lecture. Real-World Objects

Introducing the UML Eng. Mohammed T. Abo Alroos

Introduction to OOP. Procedural Programming sequence of statements to solve a problem.

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

Basic Structural Modeling. Copyright Joey Paquet,

LABORATORY 1 REVISION

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

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

Software Engineering Lab Manual

INHERITANCE & POLYMORPHISM. INTRODUCTION IB DP Computer science Standard Level ICS3U. INTRODUCTION IB DP Computer science Standard Level ICS3U

What is Inheritance?

Experiment no 4 Study of Class Diagram in Rational Rose

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

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

CS 4604: Introduction to Database Management Systems. B. Aditya Prakash Lecture #5: Entity/Relational Models---Part 1

UML Tutorial. Unified Modeling Language UML Tutorial

UML Class Diagrams Revisited

Object- Oriented Design with UML and Java Part I: Fundamentals

Use-Case Analysis. Architecture Oriented Analysis. R. Kuehl/J. Scott Hawker p. 1 R I T. Software Engineering

Interaction Modelling: Sequence Diagrams

CS111: PROGRAMMING LANGUAGE II. Lecture 1: Introduction to classes

CIS 110: Introduction to computer programming

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

For 100% Result Oriented IGNOU Coaching and Project Training Call CPD TM : ,

Unified Modeling Language (UML)

OO System Models Static Views

Object Oriented Programming: Based on slides from Skrien Chapter 2

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

Database Applications (15-415)

HAS-A Relationship. Association is a relationship where all objects have their own lifecycle and there is no owner.

Introduction to Software Engineering. 5. Modeling Objects and Classes

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

Inheritance and Polymorphism

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


Chapter 10 Object-Oriented Design Principles

Orthographic Software Modeling A Practical Approach to View Based Development

PROGRAMMING IN VISUAL BASIC WITH MICROSOFT VISUAL STUDIO Course: 10550A; Duration: 5 Days; Instructor-led

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

Unit Wise Questions. Unit-1 Concepts

Entity-Relationship Modelling. Entities Attributes Relationships Mapping Cardinality Keys Reduction of an E-R Diagram to Tables

CSCU9T4: Managing Information

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

1/24/2012. Chapter 7 Outline. Chapter 7 Outline (cont d.) CS 440: Database Management Systems

You can do this before your time period begins.

Enhanced Entity- Relationship Models (EER)

Object Oriented Features. Inheritance. Inheritance. CS257 Computer Science I Kevin Sahr, PhD. Lecture 10: Inheritance

Software Service Engineering

Unified Modeling Language (UML)

Example: Count of Points

OO Techniques & UML Class Diagrams

Object-Oriented Design

Overview. OOP: model, map, reuse, extend. Examples of objects. Introduction to Object Oriented Design

Object Oriented Modeling

More About Objects. Zheng-Liang Lu Java Programming 255 / 282

Requirements Engineering

Ingegneria del Software Corso di Laurea in Informatica per il Management. Introduction to UML

Introduction to Unified Modelling Language (UML)

The Essence of Object Oriented Programming with Java and UML. Chapter 2. The Essence of Objects. What Is an Object-Oriented System?

Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition. Chapter 7 Data Modeling with Entity Relationship Diagrams

What are the characteristics of Object Oriented programming language?

Object Orientated Analysis and Design. Benjamin Kenwright

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance

SOFTWARE DESIGN COSC 4353 / Dr. Raj Singh

Programming in Visual Basic with Microsoft Visual Studio 2010

Lecture 10 - Chapter 7 Entity Relationship Model

Interaction Modelling: Use Cases

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

CS 146 Database Systems

COP 3330 Final Exam Review

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

UML Component Diagrams A.Y 2018/2019

2.0.3 attributes: A named property of a class that describes the range of values that the class or its instances (i.e., objects) may hold.

UML Sequence Diagrams for Process Views

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

CSE 308. UML Sequence Diagrams. Reading / Reference.

UML Primer. -Elango Sundaram

Relationships. Association Aggregation/Composition Multiplicity Dependencies


Lecture 2 and 3: Fundamental Object-Oriented Concepts Kenneth M. Anderson

Database Management Systems MIT Introduction By S. Sabraz Nawaz

Conceptual Design with ER Model

Sequence Diagrams. Massimo Felici. Massimo Felici Sequence Diagrams c

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

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

Good-Enough Design. Kenneth M. Anderson University of Colorado, Boulder CSCI 5828 Lecture 11 02/17/2009

Conceptual Design. The Entity-Relationship (ER) Model

Objectives. Explain the purpose and objectives of objectoriented. Develop design class diagrams

CREATED BY: Muhammad Bilal Arslan Ahmad Shaad. JAVA Chapter No 5. Instructor: Muhammad Naveed

Exercise: Singleton 1

Inheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L

Chapter 1: Object-Oriented Programming Using C++

Design Pattern: Composite

Transcription:

Lecture 3 1.4 Object-Oriented Paradigm UML (Unified Modeling Language)

The Object-Oriented Paradigm - data and operations are paired - programs are composed of self-sufficient modules (objects) each module contains all the information needed to manipulate its own data structure and can interact with other modules (objects): send messages, receive messages, process data,... - Encapsulation, Inheritance, and Polymorphism

Objects and Classes A class defines the abstract characteristics of a thing : its attributes (or fields or properties), and its behaviors (the things it can do, or methods, operations or features). An instance of a class is called object. Objects are represented using the same group of attributes, yet the values of those attributes may or may not be the same. Attributes and methods of an object (instance of a class) are called its members.

Objects and Classes Example: the obedient dog Let's define a class Dog attributes: Name, BirthDate, Breed, HairColor, EyeColor, Weight, Gender, Location methods: Sit, LieDown, RollOver, Fetch, Speak From this class we can create lots of instances of this class, that are called objects. Sunny, Spot, Lady, To interact with them an entity calls one of its supported methods (called invoking a method); this entity is called the caller and will often be some other object in the system.

Object-Oriented Philosophy Encapsulation manages the complexity of a system. For programming this means: The internals of an object or class are invisible to the outside program (the attributes and the code for how methods work) The attributes are private (can only be accessed by code inside methods of the class) The methods are only visible by their signature (name, list of parameters and types, and the return type)

Object-Oriented Philosophy Encapsulation manages the complexity of a system. For programming this means: The internals of an object or class are invisible to the outside program (the attributes and the code for how methods work) The attributes are private (can only be accessed by code inside methods of the class) The methods are only visible by their signature (name, list of parameters and types, and the return type)

Object-Oriented Philosophy Encapsulation is also called information hiding or data abstraction Example: a TV. Notice that we don't see what's inside it. How it works. It just works and we use it choose channel, volume level and so on.

Object-Oriented Philosophy Inheritance allows similar classes to re-use the same code for their methods, as well as their attributes. this makes systems easier to maintain example: Person Name SSN parent class child class Student Faculty child class

Object-Oriented Philosophy Polymorphism allows the programmer to treat derived class members just like their parent class's members. example: Geometric Figure ID _draw(...) parent class Triangle Rectangle Oval Parallelogram... _draw(...)... _draw(...)... _draw(...)... _draw(...) children classes

Object-Oriented Philosophy For the time being let's postpone the talk about Object-Oriented Programming (OOP) and let's take a look at UML

Unified Modeling Language (UML) UML is a standardized general-purpose modeling language in the field of software engineering. The standard is managed, and was created by, the Object Management Group. There are four parts to the UML 2.x specification: 1. the Superstructure that defines the notation and semantics for diagrams and their model elements (current version: 2.2); 2. the Infrastructure that defines the core metamodel on which the Superstructure is based (current version: 2.2); 3. the Object Constraint Language (OCL) for defining rules for model elements (current version: 2.0); 4. and the UML Diagram Interchange that defines how UML 2 diagram layouts are exchanged (current version: 1.0).

UML when to use and why One of the uses of UML is in the design of a software. Is allows to visualize the software to be developed in multiple dimensions and helps to understand it. A high-level model can be built at the beginning of the project, followed by more detailed ones during the process of development of the software. After coding the ready software can be tested against a test model that is derived from the original model of requirements. There is a very nice explanation of why and what for can we use UML: http://www.cragsystems.co.uk/why_use_uml.htm

Modeling There is a difference between the UML model and the set of diagrams of a system. A diagram is a partial graphical representation of a system's model. The model is a collection of diagrams. UML diagrams represent two different views of a system mode: Static (or structural) view: Emphasizes the static structure of the system using objects, attributes, operations and relationships. Dynamic (or behavioral) view: Emphasizes the dynamic behavior of the system by showing collaborations among objects and changes to the internal states of objects.

UML diagrams Source: Wikipedia Author: Paulo Merson

Let's take a look at few of the diagrams we will be using.

Activity diagram Activity diagrams are constructed from a limited set of building blocks consisting of nodes, activities, and decisions. Although superficially similar to conventional flowcharts, activity diagrams also allow concurrent activities to be modeled. activity diagrams

Recall the Euclid's algorithm for finding GCD of two integers from Lecture 1. The flowchart we had: u is the first integer, v is the second integer Reset u to v, v to r Divide u by v, letting r be the remainder No Is v zero? Yes Value of u is the gcd activity diagrams

Activity Diagram (Flowchart) For Euclid's algorithm done in Dia 0.97: activity diagrams

Class diagram A class diagram is a type of static structure diagram that describes the structure of a system by showing the system's classes, their attributes, and the relationships between the classes. In the class diagram these classes are represented with boxes which contain three parts: The upper part holds the name of the class The middle part contains the attributes of the class, and The bottom part gives the methods or operations the class can take or undertake Class diagrams

Let's recall the example with obedient dog. We defined a class Dog with attributes: Name, BirthDate, Breed, HairColor, EyeColor, Weight, Gender, Location and methods: Sit, LieDown, RollOver, Fetch, Speak Class diagrams

Here is an example of a class hierarchy diagram: Class diagrams

Sequence diagram A sequence diagram is a kind of interaction diagram that shows how processes/objects interact with one another and in what order. different processes (objects) live simultaneously as parallel vertical lines (lifelines), and horizontal arrows show the messages exchanged between the processes in the order in which they occur. dashed arrows return messages solid arrows - calls This allows the specification of simple runtime scenarios in a graphical manner. sequence diagrams

We already have a class Dog and let Sunny be an instance (object) of that class. Let's assume that we have a class Person, and Jane is an object of this class. Let's see an example of interaction between a Jane and Sunny: sequence diagrams

1.4.3 Designing a Student Registration system Let's develop a Student Registration System. Before any implementation/coding starts its good to realize what do we want from the future system and to show the structure schematically (using diagrams): - what do we want from the system: Student should be able to register for a course, and drop it. Each course has a list of students, time, place and Professor's name. Professor has a list of courses to teach, belongs to a Department. Students have majors. Sometimes students have to meet some pre-requisites of the course to be able to take it. - To show the structure, we will define classes: Student, Professor, Course,...

Class Diagrams Person name birthdate ssn phonenumber getname() getphone() getage() setphone(number) getssn() Student curschedule transcript advisor major enroll(course) drop(course) getmajor() declaremajor(major) getgpa() getgrade(course) assigngrade(course,grade) hastaken(course) Professor department office officehours curschedule getoffice() setoffice(room) getdepartment() getofficehours() setofficehours(hours) assigngrade(course,student,grade)

- let's take a look at possible relationships between Classes. add remove Student number of credit hours room Course Course Took the prerequisite course? Student Professor List of students Course Student List of courses offered Department...

Class Diagrams Course title number prerequisite instructor classlimit listofstudents room hours getlistofstudents() addstudent(student) removestudent(student) getclasslimit() getnumopenseats() isfull() getinstructor() setinstructor(professor) gettitle() getnumhours() GetRoom() getdepartment() Department title listofinstructors listofcoursesoffered listofstuff room hours gettitle() getlistofinstructors() addinstructor(professor) removeinstructor(professor) getlistofstuff() addstuff(person) removestuff(person) getroom() getlistofcoursesoffered() addcourse(course) removecourse(course)

Sequence Diagrams enroll (csi32_2693) Crystal: Student addstudent(crystal) done (or True) csi32_2693: Course True

Sequence Diagrams Crystal: Student csi32_2693: Course enroll (csi32_2693) addstudent(crystal) isfull() False hastaken(csi31) True True True adding student (Crystal) to the roster True More refined diagram

Sequence Diagrams Bob: Student csi32_2693: Course removestudent(bob) True Bob decided to drop a class

Sequence Diagrams Alice: Professor csi32_2693: Course getlistofstudents() listofstudents getroom() CPH 123 isfull() False addstudent(crystal) True

In-class work 1. Build an activity diagram for the following algorithm: a=10 b=20 while a > 0: b+= a*b a -= 2 print(a,b)

In-class work 2. Design and draw a class diagram for a class for an online bookstore

In-class work 3. The class diagrams of an online customer and an online bookstore are given below. Tom (with id=11768) wants to check if the online bookstore named shop23 has the book Landscaping Design in stock (assume that it is in stock and has id=123) and to buy it if it is in stock. Drawn a sequence diagram modeling the purchase. Customer name customer_id email creditcard shoppingcart getcreditcard() name id bookslist shoppingcarts Bookshop searchinventory(bookname) addtocart(customer_id,book_id,) checkout(customerid)

Homework Assignment Page 29 / 1.19 Page 30 / 1.20, 1.22, 1.27, 1.31 Comments: For 1.20: The book has an answer for 1.20, but try to do it on your own first, and then, if needed, refer to the solution. Please, note that we did not create Schedule class and hence didn't use it in our scenarios, so you shouldn't use it either.