Object Oriented-Basics of Software Engineering-Lecture Slides, Slides of Software Engineering

This lecture is part of lecture series for Software Engineering course. Prof. Prateek Aron delivered this lecture at Allahabad University. Its main points are: Object-orientation, Data, Structure, Functionality, Communicate, Interface, Inheritance, Polymorphism, Dynamic, Binding

Typology: Slides

2011/2012

Uploaded on 07/16/2012

sanaka
sanaka 🇮🇳

4.6

(21)

71 documents

1 / 33

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Object-Oriented
Object orientation means to organize the software as
a collection of discrete objects that incorporate both
data structure and behaviour
System functionality is expressed in terms of object
services.
1 COMP201 - Software Engineering
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21

Partial preview of the text

Download Object Oriented-Basics of Software Engineering-Lecture Slides and more Slides Software Engineering in PDF only on Docsity!

Object-Oriented

 Object orientation means to organize the software as

a collection of discrete objects that incorporate both

data structure and behaviour

 System functionality is expressed in terms of object

services.

Object Concepts

 We continue to explore the question “what are good systems like?” by describing the object oriented paradigm.

 We shall answer these questions:

 What is an object?  How do objects communicate?  How is an object’s interface defined?  What have objects to do with components?

 Finally we consider inheritance, polymorphism and dynamic binding.

What is an Object?

 Conceptually, an object is a thing you can interact with:  you can send it various messages and  it will react

 How it behaves depends on the current internal state of the object, which may change  For example: as part of the object’s reaction to receiving a message.

 It matters which object you interact with, an object has an identity which distinguishes it from all other objects.

Again… What is an Object?

 An object is a thing which has

 behaviour,  state and  identity [Grady, Booch, 1991]

 Advantages:

 Shared data areas are eliminated. Objects communicate by message passing.  Objects are independent and encapsulate state and representation information. Their independence can lead to easier maintenance

Behaviour

 The way an object acts and reacts, in terms of its state changes as message passing.

 An object understands certain messages,

 it can receive the message and act on them.

 The set of messages that the object understands, like the set of attributes it has, is normally fixed.

Identity is more Tricky

 The idea is that objects are not defined just by the current values of their attributes

 An object has a continuous existence

 For example the values of the object’s attributes could change, perhaps in response to a message, but it would still be the same object.

Messages

 A message includes a selector ; here we’ve seen the selectors  reportTime and resetTimeTo

 A message may, but need not, include one or more arguments

 Often, for a given selector there is a single “correct” number of arguments (Recall method overloading however..)

Interfaces

 The object’s public interface defines which messages it will accept

 An object can also send to itself any message which it is capable of understanding (in either its public or private interface )

 So typically an object has two interfaces:

 The public interface (any part of the system can use)  The larger private interface (which the object itself and other privileged parts of the system can use)

Object: Classification

 objects with the same data structure (attributes) and behaviour (operations) are grouped into a class

 each class defines a possibly infinite set of objects

docsity.com

Object: Classification

 Each object is an instance of a class

 Each object knows its class

 Each instance has its own value for each attribute (state) but shares the attribute names and operations with other instances of the class  also “static” i.e. class variables

 A class encapsulates data and behaviour, hiding the implementation details of an object

Digression: Why have Classes?

 Why not just have objects, which have state, behaviour and identity as we require?

 Classes in object oriented languages serve two purposes:

 Convenient way of describing a collection (a class) of objects which have the same properties  In most modern OO languages, classes are used in the same way that types are used in many other languages  To specify what values are acceptable

Classes and Types

 Often, people think of classes and types as being the same thing (indeed it is sometimes convenient and not misleading to do so). It is not strictly correct however.

 Remember that a class does not only define what messages an object understands!

 It also defines what the object does in response to the messages.

Object: Inheritance

 Inheritance is the sharing of attributes and operations among classes based upon a hierarchical relationship

 A class can be defined broadly and then refined into successively finer subclasses

 Each subclass incorporates or inherits all of the properties of its super class and its own unique properties

Subclass  Superclass

 A subclass is an extended, specialized version of its

superclass.

 It includes the operations and attributes of the

superclass, and possibly extra ones which extend the

class.