EC-241 Object-Oriented Programming LECTURE 9. Objectives: Introduction to Object Oriented Design Revise the basic principles of object orientation Unified.

Slides:



Advertisements
Similar presentations
Introduction to Object Orientation System Analysis and Design
Advertisements

UML an overview.
Informática II Prof. Dr. Gustavo Patiño MJ
UML & Together 2006 tutorial Hong Qing Yu 10/2006.
Object-Oriented Application Development Using VB.NET 1 Chapter 5 Object-Oriented Analysis and Design.
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall A.1.
Ch 12: Object-Oriented Analysis
Informática II Prof. Dr. Gustavo Patiño MJ
2-1 © Prentice Hall, 2007 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
Introduction To System Analysis and Design
Object Oriented Analysis and Design Using the UML
Introduction to Object Modeling
Essentials of interaction diagrams Lecture Outline Collaborations Interaction on collaboration diagrams Sequence diagrams Messages from an object.
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
© Copyright Eliyahu Brutman Programming Techniques Course.
Copyright 2004 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Second Edition Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Appendix.
1 CS1001 Lecture Overview Object Oriented Design Object Oriented Design.
Unified Modeling Language
OOAD Using the UML - Introduction to Object Orientation, v 4.2 Copyright  Rational Software, all rights reserved 1 Object Oriented Analysis.
Introduction To System Analysis and design
Shanghai Jiao Tong University 上海交通大学软件工程中心 Object Oriented Analysis and Design Introduction to Object Technology.
Object Oriented Analysis and Design Using the UML Version 4.2 Introduction to Object Orientation Prepared by:Kandarp R. Somaiya.
Page 1 What is the UML? UML stands for Unified Modeling Language The UML combines the best of the best from – Data Modeling concepts (Entity Relationship.
Copyright 2001 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Appendix A Object-Oriented.
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
Unified Modeling Language, Version 2.0
3rd Country Training, K.Subieta: System Engineering and Databases. Lecture 3, Slide 1 February 20, 2004 Lecture 3: Introduction to Software Analysis and.
Systems Analysis and Design in a Changing World, Fifth Edition
Introduction To System Analysis and Design
1 Analysis Extracting from Use Cases to Create Diagrams.
CSC 395 – Software Engineering Lecture 13: Object-Oriented Analysis –or– Let the Pain Begin (At Least I’m Honest!)
CS3773 Software Engineering Lecture 04 UML Class Diagram.
® IBM Software Group © 2006 IBM Corporation Rational Software France Object-Oriented Analysis and Design with UML2 and Rational Software Modeler 02. Objects,
Systems Analysis & Design 7 th Edition Chapter 5.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 15 System Modeling with the UML.
UML diagrams What is UML UML diagrams –Static modeoing –Dynamic modeling 1.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 14 Slide 1 Object-oriented Design.
Slide 12A.1 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005 Stephen R. Schach.
Discovering object interaction. Use case realisation The USE CASE diagram presents an outside view of the system. The functionality of the use case is.
Object Oriented Analysis & Design Using UML (CS-512) M-Tech CSE (Ist & 3rd Sem) Part Time Mr. Pawan Luthra Assistant Professor (CSE Deptt.) SBSSTC, Ferozepur.
Introduction to UML CS A470. What is UML? Unified Modeling Language –OMG Standard, Object Management Group –Based on work from Booch, Rumbaugh, Jacobson.
OOAD Using the UML - Introduction to Object Orientation, v 4.2 Copyright  Rational Software, all rights reserved 1 Object Oriented Analysis.
1 Unified Modeling Language, Version 2.0 Chapter 2.
Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey A.
Object-Oriented Application Development Using VB.NET 1 Chapter 5 Object-Oriented Analysis and Design.
Object Oriented Analysis and Design Using the UML
Chapter 3: Introducing the UML
1 IBM Software Group ® Essentials of Visual Modeling with UML 2.0 Module 3: Concepts of Object Orientation.
Didik Dwi h t t p : / / b l o g. e l e k t r o. u m. a c. i d / d i d i k Object Oriented Software Engineering.
Concepts of Object Orientation lecture 1 –b. Objectives: Concepts of Object Orientation OOAD 2  Explain the basic principles of object orientation 
Basic Characteristics of Object-Oriented Systems
Unified Modeling Language. What is UML? Standard language for specifying, visualizing, constructing, and documenting the artifacts of software systems,
Modified from Sommerville’s originalsSoftware Engineering, 7th edition. Chapter 14 Slide 1 Object-Oriented Design.
UML CSE 470 : Software Engineering. Unified Modeling Language UML is a modeling language to express and design documents, software –Particularly useful.
UML Diagrams By Daniel Damaris Novarianto S..
The Movement To Objects
Object-Oriented Analysis and Design
Concepts of Object Orientation
Unified Modeling Language
UML Diagrams Jung Woo.
UML PPt by: Hong Qing Yu.
Object Oriented Analysis and Design Using the UML
Software Engineering Lecture #11.
Chapter 20 Object-Oriented Analysis and Design
CIS 375 Bruce R. Maxim UM-Dearborn
Appendix A Object-Oriented Analysis and Design
Chapter 22 Object-Oriented Systems Analysis and Design and UML
CIS 375 Bruce R. Maxim UM-Dearborn
UML & Together 2006 tutorial
Presentation transcript:

EC-241 Object-Oriented Programming LECTURE 9

Objectives: Introduction to Object Oriented Design Revise the basic principles of object orientation Unified Modeling Language (UML) Understand the basic concepts and terms of object orientation and associated UML notation

Object Orientation EncapsulationAbstraction Hierarchy Modularity Basic Principles of Object Orientation

Salesperson Not saying Which salesperson – just a salesperson in general!!! Customer Product Manages Complexity What is Abstraction?

Improves Resiliency What is Encapsulation? Hide implementation from clients – Clients depend on interface How does an object encapsulate? What does it encapsulate?

Order Processing System Billing Order Entry Order Fulfillment Manages Complexity What is Modularity? The breaking up of something complex into manageable pieces

Decreasing abstraction Increasing abstraction Elements at the same level of the hierarchy should be at the same level of abstraction Asset RealEstate Savings BankAccount Checking Stock Security Bond What is Hierarchy? Levels of abstraction

Introduction to Object Oriented Design Basic Principles of Object Orientation Unified Modeling Language (UML) Basic Concepts of Object Orientation

UML: Background OOA, OOD, and OOP Object-oriented methods may be applied to different phases in the software life-cycle e.g., Analysis, Design, implementation, etc. OO Analysis (OOA) is a process of discovery where a development team models and under-stands the requirements of the system OO Design (OOD) is a process of invention and adaptation where the development team creates the abstractions and mechanisms necessary to meet the system's behavioral requirements determined during analysis

UML: Modeling Modeling is a way of thinking about the problems using models organized around the real world ideas. A modeling method comprises a language and also a procedure for using the language to construct models. modeling is the only way to visualize your design and check it against requirements before your crew starts to code. References

Unified Modeling Language (UML) The Unified Modeling Language (UML) is a standard language for Specifying Visualizing ConstructingDocumenting Business Modeling Communications

UML: Different Views Users (Use Case Diagrams) Designers (Class Diagrams) Analyzers (State Transition Diagrams)

UML: Different Views Analyzers (Sequence Diagrams) Analyzers (Activity Diagram)

Introduction to Object Oriented Design Basic Principles of Object Orientation Unified Modeling Language (UML) Basic Concepts of Object Orientation

Object Class Attribute (Data Member) Operation (Member Function) Relationships

Basic Concepts of Object Orientation Object Class Attribute Operation Relationships

Truck Chemical Process Linked List What is an Object? Informally, an object represents an entity, either physical, conceptual, or software – Physical entity – Conceptual entity – Software entity

A More Formal Definition An object is a concept, abstraction, or thing with sharp boundaries and meaning for an application An object is something that has: – State (values of data members) – Behavior (member functions) – Identity (name of object)

: Professor Professor Clark a + b = 10 ProfessorClark : Professor ProfessorClark Class Name Only Object Name Only Class and Object Name (stay tuned for classes) Representing Objects in UML An object is represented as rectangles with underlined names

Basic Concepts of Object Orientation Object Class Attribute Operation Relationships

OO Principle: Abstraction What is a Class? A class is a description of a group of objects with common properties (attributes or data members), behavior (operations or member functions), and relationships – An object is an instance of a class A class is an abstraction in that it: – Emphasizes relevant characteristics – Suppresses other characteristics

a + b = 10 Class Course Properties Name Location Days offered Credit hours Start time End time Behavior Add a student Delete a student Get course roster Determine if it is full Sample Class

Professor Professor Clark a + b = 10 Representing Classes in UML A class is represented using a compartmented rectangle

Professor name empID create( ) save( ) delete( ) change( ) Class Name Attributes Operations Class Compartments in UML A class is comprised of three sections – The first section contains the class name – The second section shows the structure (attributes or data members) – The third section shows the behavior (operations or member functions)

Objects Class Professor SmithProfessor JonesProfessor Mellon Professor The Relationship Between Classes and Objects A class is an abstract definition of an object – It defines the structure and behavior of each object in the class – It serves as a template for creating objects Objects are grouped into classes

Basic Concepts of Object Orientation Object Class Attribute Operation Relationships

:CourseOffering number = 101 startTime = 900 endTime = 1100 :CourseOffering number = 104 startTime = 1300 endTime = 1500 CourseOffering number startTime endTime Class Attribute Object Attribute Value What is an Attribute? In UML

Basic Concepts of Object Orientation Object Class Attribute Operation Relationships

CourseOffering addStudent deleteStudent getStartTime getEndTime Class Operation What is an Operation? In UML

Basic Concepts of Object Orientation Object Class Attribute Operation Relationships

UML Class Diagrams Name Attributes Operations Relations Associations Aggregation Generalization Class diagrams show the classes of the system, their interrelationships (including inheritance, aggregation, and association), and the operations and attributes of the classes. A class diagram is used to show the existence of classes and their relationships in the logical view of a system

UML Class Diagrams essentials Class Diagrams + Public - Private # protected Thier basic relation ships Association Aggregation generalization ClassName -operationt (): return type addStudent (): int + attribute : type + coursename : string

Relations Between Classes in UML Association -- a relationship between instances of the two classes. There is an association between two classes if an instance of one class must know about the other in order to perform its work. In a diagram, an association is a link connecting two classes. Aggregation (composition) -- an association in which one class belongs to a collection. An aggregation has a diamond end pointing to the part containing the whole. Generalization -- an inheritance link indicating one class is a superclass of the other. A generalization has a triangle pointing to the superclass.

Relationships: Association MultiplicitiesMeaning 0..1zero or one instance. The notation n.. m indicates n to m instances. 0..* or *no limit on the number of instances (including none). 1exactly one instance 1..*at least one instance

Relationships: Generalization A relationship among classes where one class shares the structure and/or behavior of one or more classes Defines a hierarchy of abstractions in which a subclass inherits from one or more superclasses – Single inheritance – Multiple inheritance Generalization is an “is-a-kind of” relationship

Account balance name number Withdraw() CreateStatement() Checking Withdraw() Savings GetInterest() Withdraw() Superclass (parent) Subclasses Generalization Relationship Ancestor Descendents Example: Single Inheritance in UML One class inherits from another

AirplaneHelicopterWolfHorse FlyingThingAnimal Bird multiple inheritance Use multiple inheritance only when needed, and always with caution ! Example: Multiple Inheritance in UML A class can inherit from several other classes

Use case diagrams are used to depict the context of the system to be built and the functionality provided by that system. They depict who (or what) interacts with the system. They show what the outside world wants the system to do. Essentials of Use case Diagram Actors, which represent users of a system, including human users and other systems. Use Cases, which represent functionality or services provided by a system to users. Use case diagrams

39 Example Use Case diagram Online shopping Actor Actor: An actor is a person, organization, or external system that plays a role in one or more interactions with your system Use case Use case: A use case describes a sequence of actions that provide something of measurable value to an actor and is drawn as a horizontal ellipse System boundary System boundary: indicates the scope of your system. Anything within the box represents functionality that is in scope and anything outside the box is not

Use case example

Sequence Diagrams describe interactions among classes. These interactions are modeled as exchange of messages. These diagrams focus on classes and the messages they exchange to accomplish some desired behavior. Sequence diagrams are a type of interaction diagrams. Sequence diagrams contain the following elements: Class roles, which represent roles that objects may play within the interaction. Lifelines, which represent the existence of an object over a period of time. (A dashed vertical line, called the lifeline, is drawn below each object.) Activations, which represent the time during which an object is performing an operation. Represented by rectangle Messages, which represent communication between objects. The notation used for messages (i.e., the line type and arrowhead type) indicates the type of message being used, Sequence Diagram

A sequence diagram is – An interaction diagram that details how operations are carried out. – What messages are sent and when. – Sequence diagrams are organized according to time

43 Example Sequence Diagram Object: Class Lifeline Operations Message

Activity Diagram Activity diagrams describe the workflow behaviour of a system Activity diagrams provide visual depictions of the flow of activities, whether in a system, business, workflow, or other process. Essentials of activity Diagrams: – Action nodes – Control nodes initial and final decision and merge fork and joint

45 Example Activity Diagram : processing an order. Start Fork Branch Merge Joint End

State Transition Diagram A State Transition diagram shows the possible states of the object and the transitions that cause a change in state. State machine diagrams are used to design and understand time-critical systems (real time processing) in which the consequences of improper timing are severe Essential – Initial final and simple states

47 Example State Transition Diagram for an Order object

Example State Transition Diagram

Example: Elevator Problem A product is to be installed to control elevators in a building with m floors. The problem concerns the logic required to move elevators between floors according to the following constraints: – Each elevator has a set of m buttons, one for each floor. These illuminate when pressed and cause the elevator to visit the corresponding floor. The illumination is cancelled when the elevator visits the corresponding floor. – Each floor, except the first floor and top floor has two buttons, one to request an up-elevator and one to request a down-elevator. These buttons illuminate when pressed. The illumination is cancelled when an elevator visits the floor and then moves in the desired direction. – When an elevator has no requests, it remains at its current floor with its doors closed.

Use case Diagram A generalized description of how a system will be used. Provides an overview of the intended functionality of the system. Understandable by laymen as well as professionals

Elevator basic scenario that can be extracted from Use Case Diagram: – Passenger pressed floor button – Elevator system detects floor button pressed – Elevator moves to the floor – Elevator doors open – Passenger gets in and presses elevator button – Elevator doors closes – Elevator moves to required floor – Elevator doors open – Passenger gets out – Elevator doors closes

Class Diagram Class diagrams show the static structure of the object, their internal structure, and their relationships.

Sequence Diagram Sequence Diagram for Serving Elevator Button

Sequence Diagram for Serving Door Button

Detail Class Diagram

Reference to/content/uml-example.html to/content/uml-example.html Recommended books – Object Oriented Analysis and Design with Application By Grady Booch, Third Edition (Chapter 5) – How to Program c++ By Dietel (our Text book)

Other Examples A simple digital watch has a display and two buttons to set it, the A button and the B button. Thewatch has two modes of operation, display time and set time. In the display time mode, hours andminutes are displayed, separated by a flashing colon. The set time mode has two modes, sethours and set minutes. The A button is used to select modes. Each time A is pressed, the modeadvances in sequence: display, set hours, set minutes, display etc. Within the sub modes, the Bbutton is used to advance the hours or minutes once each time it is pressed. Buttons must be released before they can generate another event. Prepare a state diagram of the watch. Simple Digital Watch