Course: Software Engineering © Dr Alessandra RussoUnit 5: Aggregation and Inheritance, slide number 1 Unit 5: Aggregation and Inheritance This unit aims.

Slides:



Advertisements
Similar presentations
Design by Contract.
Advertisements

Chapter 7 Testing Class Hierarchies. SWE 415 Chapter 7 2 Reading Assignment  John McGregor and David A. Sykes, A Practical Guide to Testing Object-Oriented.
Inheritance “a mechanism for propagating properties (attributes & methods) of superclasses to subclasses.”
Ch 12: Object-Oriented Analysis
UML – Class Diagrams.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 4- 1.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. slide 1 CS 125 Introduction to Computers and Object- Oriented Programming.
1 Software Testing and Quality Assurance Lecture 28 – Testing Class Hierarchies.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 4 Enhanced Entity-Relationship (EER) Modeling.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. slide 1 CS 125 Introduction to Computers and Object- Oriented Programming.
© Copyright Eliyahu Brutman Programming Techniques Course.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Lecture 1 Introduction to Computers and Object-
Chapter 10 Classes Continued
Systems Design. Analysis involves understanding and documenting user requirements in a clear and unambiguous way. It focuses on the business side and.
Inheritance and Subclasses in Java CS 21a: Introduction to Computing I Department of Information Systems and Computer Science Ateneo de Manila University.
Objects What are Objects Observations
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 1 Introduction to Object-Oriented Programming and.
1 A Student Guide to Object- Orientated Systems Chapter 4 Objects and Classes: the basic concepts.
OBJECT AND CLASES: THE BASIC CONCEPTS Pertemuan 8 Matakuliah: Konsep object-oriented Tahun: 2009.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 7 Slide 1 System models l Abstract descriptions of systems whose requirements are being.
1 CS 456 Software Engineering. 2 Contents 3 Chapter 1: Introduction.
(C) 2010 Pearson Education, Inc. All rights reserved. Java How to Program, 8/e.
5 Systems Analysis and Design in a Changing World, Fourth Edition.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Stephenson College DP 96 1 Object-Orientation by Derek Peacock.
Object-Oriented Software Development F Software Development Process F Analyze Relationships Among Objects F Class Development F Class Design Guidelines.
Lab 04.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 8 Slide 1 Object-oriented and Structured System Models.
Course: Software Engineering ©Alessandra RussoUnit 2: States and Operations, slide number 1 States and Operations This unit aims to:  Define: State schemas.
OBJECT-ORIENTED PROGRAMMING (OOP) WITH C++ Instructor: Dr. Hany H. Ammar Dept. of Electrical and Computer Engineering, WVU.
Object-Oriented Analysis and Design. Lesson 1: Introduction to Software Engineering.
BCS 2143 Object Oriented Design Using UML. Objectives Objects Interactions Finding Classes Relationship Between Classes Attribute and Operation Class.
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.
Course: Software Engineering - Design I Unit 3: Classes and ObjectsSlide Number 1 Classes and Objects  Define: Class schemas to specify object classes.
What is Object-Oriented?  Organization of software as a collection of discreet objects that incorporate both data structure and behavior.
Enhanced Entity-Relationship (EER) Modeling. Slide 4- 2 Chapter Outline EER stands for Enhanced ER or Extended ER EER Model Concepts Includes all modeling.
Object Oriented Analysis and Design Class and Object Diagrams.
Chapter 13 ATM Case Study Part 2: Implementing an Object-Oriented Design Java How to Program, 8/e (C) 2010 Pearson Education, Inc. All rights reserved.
Software Engineering Zhang Shuang
Slide 1 Systems Analysis and Design With UML 2.0 An Object-Oriented Approach, Second Edition Chapter 2: Introduction to Object-Oriented Systems Analysis.
Chapter 12 Object-oriented design for more than one class.
Object-Oriented Programming © 2013 Goodrich, Tamassia, Goldwasser1Object-Oriented Programming.
Object Oriented Programming: Inheritance Chapter 9.
© Shamkant B. Navathe CC Enhanced Entity-Relationship Copyright © 2004 Ramez Elmasri and Shamkant Navathe.
Inheritance and Subclasses CS 21a. 6/28/2004 Copyright 2004, by the authors of these slides, and Ateneo de Manila University. All rights reserved L16:
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Object-Oriented Software Engineering Practical Software Development using UML and Java Modelling with Classes.
Methodology Review Chapter 7 Part 2: Design Methodology Object-Oriented Modeling and Design Byung-Hyun Ha
© 2004 Pearson Addison-Wesley. All rights reserved January 23, 2006 Creating Objects & String Class ComS 207: Programming I (in Java) Iowa State University,
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 4- 1.
Unit 1 - Introducing Abstract Data Type (ADT) Part 1.
UML (Unified Modeling Language)
Query Languages Language in which user requests information from the database. Categories of languages Procedural Non-procedural, or declarative “Pure”
5 Systems Analysis and Design in a Changing World, Fourth Edition.
Enhanced Entity-Relationship (EER) Model
DATA REQIREMENT ANALYSIS
OBJECT ORIENTED CONCEPT
A Survey of Object Orientation in Z
Creating Objects & String Class
Section 11.1 Class Variables and Methods
UML Class Diagrams: Basic Concepts
Object-Oriented Programming
Lecture 4 of 42 Relational Joins Wednesday, 30 January 2008
Instructor: Mohamed Eltabakh
Systems Analysis – ITEC 3155 Modeling System Requirements – Part 2
Software Engineering System Modeling Chapter 5 (Part 1) Dr.Doaa Sami
Enhanced Entity-Relationship (EER) Modeling
Enhanced Entity-Relationship (EER) Modeling
Presentation transcript:

Course: Software Engineering © Dr Alessandra RussoUnit 5: Aggregation and Inheritance, slide number 1 Unit 5: Aggregation and Inheritance This unit aims to:  Define the specification in Object-Z of more elaborated object- oriented systems built upon Objects aggregation Inheritance  Illustrate these aspects by considering the example of a banking system that further extends the example credit card accounts system seen in Unit 4. Aims and Objectives

Course: Software Engineering © Dr Alessandra RussoUnit 5: Aggregation and Inheritance, slide number 2 Example: A Banking System Making many simplifying assumptions: The system is an aggregate of (set of) credit card account objects. All credit card objects have limit equal to fixed commonlimit. At the beginning, the aggregate is empty. New initialised account object can be added to the aggregate. Any account object in the aggregate can be deleted. Each account object can independently perform withdraw, deposit, withdrawAvail operations. The system shall allow for any given two account objects in the aggregate to transfer the available fund of the first account into the second account.

Course: Software Engineering © Dr Alessandra RussoUnit 5: Aggregation and Inheritance, slide number 3 State Schema for the Class “Banking” Assume commonlimit to be a constant, whose value is either 1000, or 2000, or The state of the class “Banking” includes an attribute cards that is a set of credit card account objects. N commonlimit: N commonlimit  {1000, 2000, 5000} F cards : F CreditCard  c : cards.(c.limit = commonlimit) Informally cards =  Init Declaration of aggregate as attribute: cards is a finite set of object identities All the accounts objects in the aggregate have the limit equal to commonlimit The initial configuration of this system is when the aggregate is empty.

Course: Software Engineering © Dr Alessandra RussoUnit 5: Aggregation and Inheritance, slide number 4 Adding and Deleting Objects  (cards) newcard?: CreditCard newcard?  cards newcard?.Init newcard?.limit = commonlimit cards' = cards  {newcard?} Add  (cards) cards?: CreditCard card?  cards cards' = cards /{card?} Delete newcards? is genuinely new newcard? is initialised Why do we need this axiom? card? is in the aggregate

Course: Software Engineering © Dr Alessandra RussoUnit 5: Aggregation and Inheritance, slide number 5 Selecting Objects from Aggregates The system has to perform the operations of withdraw, deposit and withdrawAvail on the individual account objects that are in the aggregate. Informally We need to promote these object’s operations to operations of the Banking system. This requires a formal notation for selecting the object from the aggregate to which the operation is applied. withdraw = [card? : cards]. card?.withdraw deposit = [card? : cards]. card?.deposit Selection (from the environment) of a particular object in the aggregate to which the operation is applied. Only the state of the object identified by card? is changed in the aggregate

Course: Software Engineering © Dr Alessandra RussoUnit 5: Aggregation and Inheritance, slide number 6 Selecting more than one Object The system has to allow a “transferAvail” operation to take place between two given credit card account objects. The fund available has to be transferred from the first object to the second object. Informally transferAvail = [from?, to? : cards | from?  to?]. from?.withdrawAvail || to?.deposit Selection from the set cards of two distinct credit card account objects. These are selected by input from the environment.

Course: Software Engineering © Dr Alessandra RussoUnit 5: Aggregation and Inheritance, slide number 7 The “Banking” Class Schema Banking | (commonlimit, Init, Add, Delete, withdraw, deposit, withdrawAvail, transferAvail) F cards : F CreditCard  c : cards. c.limit = commonlimit cards =  Init  (cards) card? : CreditCard card?  cards card?.limit = commonlimit card?.Init cards' = cards  {card?} Add withdraw = [card?:cards]. card?.withdraw N commonlimit: N commonlimit  {1000, 2000, 5000}  (cards) card? : CreditCard card?  cards cards' = cards / {card?} Delete deposit = [card?:cards]. card?.deposit withdrawAvail = [card?:cards].card?.withdrawAvail transferAvail = [from?:cards, to?:cards | from?  to?]. from?.withdrawAvail || to?.deposit.

Course: Software Engineering © Dr Alessandra RussoUnit 5: Aggregation and Inheritance, slide number 8 Inheritance In Object-Z formal specification: » specifications can be developed incrementally existing Object-Z classes can be reused to define new Object-Z classes » architectural design aspects of the future system are captured inheritance hierarchy of class schemas expresses the class inheritance hierarchy of the future implementation » inheritance can be single: a “subclass” inherits just one other class multiple: a “subclass” inherits more than one other class In object-oriented programming language: code of existing classes can be reused in coding new classes.

Course: Software Engineering © Dr Alessandra RussoUnit 5: Aggregation and Inheritance, slide number 9 Example: Specialising the Class CreditCard CreditCard CreditCardCountCreditCardConfirm CreditCard class schema is as defined in Unit4 CreditCardCount class schema refines CreditCard class schema » the operation withdraw has also to count the number of withdrawals made CreditCardConfirm class schema extends CreditCard class schema » it also includes an operation that first performs the withdraw operation and then confirms it by producing as output the value of the remaining funds.

Course: Software Engineering © Dr Alessandra RussoUnit 5: Aggregation and Inheritance, slide number 10 Class Schema “CreditCardCount” | (limit, balance, Init, withdraw, deposit, withdrawAvail) N withdrawals: N withdrawals = 0 Init CreditCard  (withdrawals) withdrawals' = withdrawals + 1 withdraw CreditCardCount Inheritance

Course: Software Engineering © Dr Alessandra RussoUnit 5: Aggregation and Inheritance, slide number 11 Joining Features (state schemas) The “full” state schema of CreditCardCount: CreditCard Z balance: Z balance + limit  0 ……. CreditCardCount N withdrawal: N CreditCard ……. Z balance: Z N withdrawal: N balance + limit  0 Attributes declared in both schemas must be of the same type. Axioms in the subclass may refer to attributes defined in the superclass. Unintentional name clashes must be resolved by renaming attributes.

Course: Software Engineering © Dr Alessandra RussoUnit 5: Aggregation and Inheritance, slide number 12 Joining Features (Init schemas) The “full” Initial schema of CreditCardCount: CreditCard ……. CreditCardCount CreditCard ……. balance = 0 withdrawal = 0 Axioms are joined together withdrawals = 0 Init balance = 0 Init

Course: Software Engineering © Dr Alessandra RussoUnit 5: Aggregation and Inheritance, slide number 13 Joining Features (operation schemas) The “full” operation “withdraw”: CreditCard ……. N  (balance) amount?:N balance' = balance – amount? withdraw CreditCardCount CreditCard …….  (withdrawals) withdrawals' = withdrawals +1 withdraw N  (withdrawals, balance) amount?:N amount?  balance + limit balance' = balance – amount? withdrawals' = withdrawals +1 withdraw  lists are merged Unintentional operation name clashes are resolved by renaming.

Course: Software Engineering © Dr Alessandra RussoUnit 5: Aggregation and Inheritance, slide number 14 Renaming Existing Features CreditCardCount CreditCard[oldwithdraw/withdraw]  (withdrawals) withdrawals' = withdrawals +1 incrementCount withdraw = oldwithdraw  incrementCount Rename the operation in superclass Introduce a new operation Use the old operation name as a new operation name in the subclass

Course: Software Engineering © Dr Alessandra RussoUnit 5: Aggregation and Inheritance, slide number 15 Class Schema “CreditCardConfirm” | (limit, balance, Init, withdraw, deposit, withdrawAvail, withdrawConfirm ) CreditCard N funds!: N funds! = balance + limit fundsAvail CreditCardConfirm withdrawConfirm = withdraw fundsAvail 0 9 sequential composition operator

Course: Software Engineering © Dr Alessandra RussoUnit 5: Aggregation and Inheritance, slide number 16 Summary Aggregates » Collection of objects of the same class » Use of selection expression in class operations Inheritance » Refining or extending existing super-classes with subclasses » Joining features between subclasses and their super-classes » Sequential Composition operator.