What Is Object-Orientation?

Slides:



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

Chapter 7 System Models.
© 2010 Bennett, McRobb and Farmer1 Requirements Analysis 1: Requirements and Classes Based on Chapter 7 of Bennett, McRobb and Farmer: Object Oriented.
Systems Analysis and Design 8th Edition
Solutions to Review Questions. 4.1 Define object, class and instance. The UML Glossary gives these definitions: Object: an instance of a class. Class:
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 8 Slide 1 System modeling 2.
Object-Oriented Analysis and Design
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 8 Slide 1 System models.
COMP1007 Intro to Requirements Analysis © Copyright De Montfort University 2002 All Rights Reserved COMP1007 Intro to Requirements Analysis Object Oriented.
Object Oriented System Development with VB .NET
Modified from Sommerville’s originalsSoftware Engineering, 7th edition. Chapter 8 Slide 1 System models.
© 2005 Prentice Hall8-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
Basic OOP Concepts and Terms
©Ian Sommerville 2000Software Engineering, 6/e, Chapter 71 System models l Abstract descriptions of systems whose requirements are being analysed.
Requirements Analysis 9. 1 OO Concepts b509.ppt © Copyright De Montfort University 2000 All Rights Reserved INFO2005 Requirements Analysis Object.
Systems Analysis & Design Sixth Edition Systems Analysis & Design Sixth Edition Toolkit Part 5.
03/12/2001 © Bennett, McRobb and Farmer What Is Object-Orientation? Based on Chapter 4 of Bennett, McRobb and Farmer: Object Oriented Systems Analysis.
Object-Oriented Analysis: some basic principles. Objects “Objects have state, behaviour and identity.” Booch (1994) State: the condition of an object.
Sharif University of Technology Session # 7.  Contents  Systems Analysis and Design  Planning the approach  Asking questions and collecting data 
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 7 Slide 1 System models l Abstract descriptions of systems whose requirements are being.
Refining the Requirements Model
Basic Concepts Introduction to OO Development and Software Engineering Principles SYSC System Analysis and Design.
OBJECT ORIENTED PROGRAMMING CONCEPTS ISC 560. Object-oriented Concepts  Objects – things names with nouns  Classes – classifications (groups) of similar.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 7 Slide 1 System models l Abstract descriptions of systems whose requirements are being.
Chapter 4 System Models A description of the various models that can be used to specify software systems.
System models Abstract descriptions of systems whose requirements are being analysed Abstract descriptions of systems whose requirements are being analysed.
1 WXGC6102: Object-Oriented Techniques What Is Object-Orientation? References: Chapter 4 of Bennett, McRobb and Farmer: Object Oriented Systems Analysis.
What Is Object-Orientation?
©Ian Sommerville 1995/2000 (Modified by Spiros Mancoridis 1999) Software Engineering, 6th edition. Chapter 7 Slide 1 System models l Abstract descriptions.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Chapter 7 System models.
Systems Analysis and Design in a Changing World, 6th Edition 1 Chapter 4 Domain Classes.
System models l Abstract descriptions of systems whose requirements are being analysed.
Modified by Juan M. Gomez Software Engineering, 6th edition. Chapter 7 Slide 1 Chapter 7 System Models.
Software Engineering, 8th edition Chapter 8 1 Courtesy: ©Ian Somerville 2006 April 06 th, 2009 Lecture # 13 System models.
Sommerville 2004,Mejia-Alvarez 2009Software Engineering, 7th edition. Chapter 8 Slide 1 System models.
Systems Analysis & Design 7 th Edition Chapter 5.
Systems Analysis and Design 8 th Edition Chapter 6 Object Modeling.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 7 Slide 1 Chapter 7 System Models.
An Introduction to the Unified Modeling Language
Basic OOP Concepts and Terms. In this class, we will cover: Objects and examples of different object types Classes and how they relate to objects Object.
© 2010 Bennett, McRobb and Farmer1 Requirements Analysis 2: Realizing Use Cases Based on Chapter 7 of Bennett, McRobb and Farmer: Object Oriented Systems.
Relationships Relationships between objects and between classes.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 8 Slide 1 System models.
 To explain why the context of a system should be modelled as part of the RE process  To describe behavioural modelling, data modelling and object modelling.
Object-Oriented Software Engineering Practical Software Development using UML and Java Modelling with Classes.
CHAPTER 6 OBJECT ANALYSIS.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 8 Slide 1 System models.
2-1 © Prentice Hall, 2004 Chapter 2: Introduction to Object Orientation Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph.
Engineering, 7th edition. Chapter 8 Slide 1 System models.
5 Chapter 5: Modeling Systems Requirements: Events and Things Systems Analysis and Design in a Changing World.
Object-Oriented Modeling
Business System Development
The Movement To Objects
Systems Analysis and Design
CHAPTER 5 GENERAL OOP CONCEPTS.
Object-Oriented Analysis and Design
Systems Analysis and Design With UML 2
Object Oriented Concepts -I
Abstract descriptions of systems whose requirements are being analysed
Object Oriented Concepts
The Object Oriented Approach to Design
UML Class Diagrams: Basic Concepts
Software Engineering Lecture #11.
Chapter 20 Object-Oriented Analysis and Design
Basic OOP Concepts and Terms
Chapter 5.
Chapter 22 Object-Oriented Systems Analysis and Design and UML
Object-Oriented PHP (1)
Refining the Requirements Model
Presentation transcript:

What Is Object-Orientation? Based on Chapter 4 of Bennett, McRobb and Farmer: Object Oriented Systems Analysis and Design Using UML, (4th Edition), McGraw Hill, 2010. © 2010 Bennett, McRobb and Farmer

In This Lecture You Will Learn: The fundamental concepts of object-orientation, including: Objects and classes Generalization, specialization and inheritance Information hiding and message passing The justifications for an object-oriented approach Note for lecturers: these slides do not include coverage of how O-O is used in practice. Extra material could be usefully added to show: practical examples of O-O systems facilities of modern O-O languages typical applications and also limitations of O-O. © 2010 Bennett, McRobb and Farmer

© 2010 Bennett, McRobb and Farmer Objects An object is: “an abstraction of something in a problem domain, reflecting the capabilities of the system to keep information about it, interact with it, or both.” Coad and Yourdon (1990) © 2010 Bennett, McRobb and Farmer

© 2010 Bennett, McRobb and Farmer Objects “Objects have state, behaviour and identity.” Booch (1994) State: the condition of an object at any moment, affecting how it can behave Behaviour: what an object can do, how it can respond to events and stimuli Identity: each object is unique © 2010 Bennett, McRobb and Farmer

© 2010 Bennett, McRobb and Farmer Examples of Objects Object Identity Behaviour State Studying, resting, qualified. A person. ‘Hussain Pervez.’ Speak, walk, read. My favourite button white denim shirt. A shirt. Shrink, stain, rip. Pressed, dirty, worn. A sale. Sale no #0015, 18/05/05. Earn loyalty points. Invoiced, cancelled. A useful exercise for the class would be to suggest other behaviours and states for these objects, and to describe: How external events and object behaviour can both result in a change of state How state restricts the possible behaviours of an object A bottle of ketchup. This bottle of ketchup. Spill in transit. Unsold, opened, empty. © 2010 Bennett, McRobb and Farmer

© 2010 Bennett, McRobb and Farmer Class and Instance All objects are instances of some class A Class is a description of a set of objects with similar: features (attributes, operations, links); semantics; constraints (e.g. when and whether an object can be instantiated). OMG (2009) We don’t go into relationships and semantics at all here. Nor do we discuss attributes, operations and methods in any detail. All will be covered more extensively in later material, but lecturers may wish to add more explanation here. © 2010 Bennett, McRobb and Farmer

© 2010 Bennett, McRobb and Farmer Class and Instance An object is an instance of some class So, instance = object but also carries connotations of the class to which the object belongs Instances of a class are similar in their: Structure: what they know, what information they hold, what links they have to other objects Behaviour: what they can do © 2010 Bennett, McRobb and Farmer

Generalization and Specialization Classification is hierarchic in nature For example, a person may be an employee, a customer, a supplier of a service An employee may be paid monthly, weekly or hourly An hourly paid employee may be a driver, a cleaner, a sales assistant © 2010 Bennett, McRobb and Farmer

Specialization Hierarchy More general (superclasses) Person Employee Customer Supplier monthly paid weekly paid hourly paid It would be a useful class exercise to: add more detail to other parts of this hierarchy to suggest ways in which the various subclasses differ from each other in behaviour and structure. More specialized (subclasses) Driver Cleaner Sales assistant © 2010 Bennett, McRobb and Farmer

Generalization and Specialization More general bits of description are abstracted out from specialized classes: SystemsAnalyst Driver name employee-no startDate monthlySalary grade name employee-no startDate standardHourlyRate overtimeRate licenceType © 2010 Bennett, McRobb and Farmer

Specialized (subclasses) SystemsAnalyst General (superclass) monthlySalary grade Employee name employee-no startDate Driver standardHourlyRate overtimeRate licenceType © 2010 Bennett, McRobb and Farmer

© 2010 Bennett, McRobb and Farmer Inheritance The whole description of a superclass applies to all its subclasses, including: Information structure (including associations) Behaviour Often known loosely as inheritance (But actually inheritance is how an O-O programming language implements generalization / specialization) © 2010 Bennett, McRobb and Farmer

© 2010 Bennett, McRobb and Farmer SystemsAnalyst monthlySalary grade Employee name employee-no startDate Driver standardHourlyRate overtimeRate licenceType All characteristics of the superclass are inherited by its subclasses © 2010 Bennett, McRobb and Farmer

© 2010 Bennett, McRobb and Farmer Instances of each subclass include the characteristics of the superclass (but not usually shown like this on diagrams) :SystemsAnalyst name employee-no startDate monthlySalary grade :Driver name employee-no startDate standardHourlyRate overtimeRate licenceType © 2010 Bennett, McRobb and Farmer

© 2010 Bennett, McRobb and Farmer Message-passing Several objects may collaborate to fulfil each system action “Record CD sale” could involve: A CD stock item object A sales transaction object A sales assistant object These objects communicate by sending each other messages I have called this a ‘system action’ because the proper term ‘use case’ may not yet have been introduced. It would probably be useful to add a forward pointer to the lecture where use cases are discussed. A possible exercise would be for the class to discuss and suggest how these objects might participate in the use case, and what operations and attributes are implied by the interaction. © 2010 Bennett, McRobb and Farmer

Message-passing and Encapsulation Message from another object requests a service. Operation signature is an interface through which an operation can be called. Operations are located within an object. Data used by an operation is located in the object too ‘Layers of an onion’ model of an object: An outer layer of operation signatures… …gives access to middle layer of operations… This is the only mention of encapsulation in these slides. It may be worth adding more material and spending a little time explaining the significance of this concept. …which access an inner core of data © 2010 Bennett, McRobb and Farmer

Information Hiding: a strong design principle Message from another object requests a service. Operations can only be called by message with valid operation signature. Only object’s own operations can access its data. Representation of data is hidden inside object ‘Layers of an onion’ model of an object: Only the outer layer is visible to other objects… …and it is the only way to access operations… …which are the only way to access the hidden data © 2010 Bennett, McRobb and Farmer

© 2010 Bennett, McRobb and Farmer Polymorphism Polymorphism allows one message to be sent to objects of different classes Sending object need not know what kind of object will receive the message Each receiving object knows how to respond appropriately For example, a ‘resize’ operation in a graphics package The ‘resize’ example will need more explanation than this. What I had in mind was the way that circles, rectangles, bitmaps, groups of objects, etc will all need their own distinct methods to implement the operation. However, from the perspective of a user (or indeed a boundary object) all are called in the same way. The class could be asked to suggest other examples of polymorphism, and to explain what is polymorphic about each. © 2010 Bennett, McRobb and Farmer

Polymorphism in Resize Operations Campaign title campaignStartDate campaignFinishDate getCampaignAdverts() addNewAdvert() <<entity>> © 2010 Bennett, McRobb and Farmer

© 2010 Bennett, McRobb and Farmer Advantages of O-O Can save effort Reuse of generalized components cuts work, cost and time Can improve software quality Encapsulation increases modularity Sub-systems less coupled to each other Better translations between analysis and design models and working code This slide covers the point only in bare outline. Extra material could usefully be added to show the advantages of and justifications for O-O in more detail. © 2010 Bennett, McRobb and Farmer

© 2010 Bennett, McRobb and Farmer Summary In this lecture you have learned about: The fundamental concepts of O-O Object, class, instance Generalization and specialization Message-passing and polymorphism Some of the advantages and justifications of O-O © 2010 Bennett, McRobb and Farmer

© 2010 Bennett, McRobb and Farmer References Coad and Yourdon (1990) Booch (1994) OMG (2009) (For full bibliographic details, see Bennett, McRobb and Farmer) Lecturers may wish to add their own further reading here, or to give full details for these references. © 2010 Bennett, McRobb and Farmer