Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta...

55
Title : Object Oriented Systems Paper Code : CA - 205 Course : MCA Faculty : Ms. Charu Sharma Vikrant Gupta Course Description:

Transcript of Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta...

Page 1: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Title : Object Oriented Systems

Paper Code : CA - 205

Course : MCA

Faculty : Ms. Charu Sharma

Vikrant Gupta

Course Description: 

Page 2: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

The course aims is to introduce the students to Object Oriented Programming Concepts with special emphasis on Object Oriented

Programming in C++.

The course begins with a gentle introduction to OOAD and OOP concepts. Students will then be presented with detailed discussion of Object Oriented Programming features in C++. At the end the use of few applications of OOAD and OOP concepts in areas like Software Engineering and Operating Systems.

In order to take the course the student should be familiar with Digital Computer System and must have completed a basic course in Computer Programming, preferably in C.  

Course Objectives & Prerequisites:  

Page 3: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Object Oriented Programming

Page 4: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Programming evolution Machine code ● programs in binary code, executed directly by the processor Assembly languages ● still low level programming, replaced machine code functions with

mnemonics and memory addresses with symbolic labels

Procedural programming ● decompose programs into procedures/functions

Modular Programming ● decompose programs into modules

Object Oriented Programming ● decompose program into a set of objects ● objects interact with each other to form a system

Page 5: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

What is OOP?

OOP is a design philosophy. It stands for Object Oriented Programming. Object-Oriented Programming (OOP) uses a different set of programming languages than old procedural programming languages (C, Pascal, etc.). Everything in OOP is grouped as self sustainable "objects“.

Page 6: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

What is OOP?(Cont’d) In order to clearly understand the object

orientation, let’s take your “hand” as an example. The “hand” is a class. Your body has two objects of type hand, named left hand and right hand. Their main functions are controlled/ managed by a set of electrical signals sent through your shoulders (through an interface). So the shoulder is an interface which your body uses to interact with your hands. The hand is a well architected class. The hand is being re-used to create the left hand and the right hand by slightly changing the properties of it.

Page 7: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Problem Description“ customers are allowed to have different

types of bank accounts, deposit money, withdraw money and transfer money between accounts”

Page 8: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Procedural Approach

bool MakeDeposit(int accountNum,float amount);float Withdraw(int accountNum,float amount);

struct Account {char *name;int accountNum;float balance;char accountType;

};

Page 9: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Procedural Approach cont’dFocus is on procedures

All data is shared: no protection

More difficult to modify

Hard to manage complexity

Page 10: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Procedural vs. Object-Oriented

Procedural

Withdraw, deposit, transfer

Object Oriented

Customer, money, account

Page 11: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Mapping the world to software

Objects in the problem domain are mapped to objects in software

011101

10011

11101

0110100

11010

010101

1110101

10101

Page 12: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Object OrientedData and operations are grouped together

Account

Deposit

Withdrawl

Transfer

Interface:

Set of available operations

Page 13: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Object Oriented ParadigmProvide flexible and powerful abstraction Allow programmers to think in terms of the structure of the

problem rather than in terms of the structure of the computer.

● Decompose the problem into a set of objects

● Objects interact with each other to solve the problem

● create new type of objects to model elements from the problem space

An object is an entity that:● has a local state● able perform some operation (behavior)

Page 14: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Object Oriented Paradigm(Cont’d)It may be viewed as a combination of: ● data (attributes) ● procedural elements (methods)

Object Oriented Programming is a method of implementation where:

objects are fundamental building blocks ● each object is an instance of some type (class) ● classes are related to each others by inheritance

Page 15: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Fundamental concepts and propertiesConcepts: ● object ● class ● method (message)

Properties: ● encapsulation ● inheritance ● polymorphism

Page 16: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Objects and Classes

Classes reflect concepts, objects reflect instances that embody those concepts.

Daria Jane BrittanyJodie

girlclassobject

Page 17: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Objects and Classes (cont’d)

A class captures the common properties of the objects instantiated from it

A class characterizes the common behavior of all the objects that are its instances

Page 18: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Objects and Classes (cont’d)

Class BankAccount

BalanceInterestYTDOwnerAccount_number

Balance 500InterestYTDOwner Account_number

Balance 10,000InterestYTDOwner Account_number

Operations

MakeDesposit

Transfer

WithDraw

GetBalance

Page 19: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Objects as instances of Classes

The world conceptually consists of objects Many objects can be said to be of the same

type or classMy bank account, your bank account, Bill

Gates’ bank account … We call the object type a class

Page 20: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

InstantiationAn Object is instantiated from a Class

BankAccount myAccount;

myAccount = new BankAccount;

Page 21: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Objects and Classes

ClassVisible in source

codeThe code is not

duplicated

ObjectOwn copy of dataActive in running

programOccupies memoryHas the set of

operations given in the class

Page 22: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Classification

Mammal

Rodent Primate Cats

Reptile

Animal

Squirel RabbitMouse

Page 23: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Classification

Checking Account

Value First Select Access First Interest

Savings Account

Account

Page 24: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Encapsulation

Abstraction in OOP is closely related to a concept called encapsulation. Data and the ways to get at that data are wrapped in a single package, a class. The only way to access such data is through that package. This idea translates to information hiding.

Page 25: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Encapsulation (Cont’d)

Encapsulation is the method of combining the data and functions inside a class. This hides the data from being accessed from outside a class directly, only through the functions inside the class is able to access the information.This is also known as "Data Abstraction", as it gives a clear separation between properties of data type and the associated implementation details. There are two types, they are "function abstraction" and "data abstraction". Functions that can be used without knowing how its implemented is function abstraction. Data abstraction is using data without knowing how the data is stored.

Page 26: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Data Encapsulation

class Account {

public:

float withdraw();

void deposit(float amount);

private:

float balance;

);

Page 27: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Advantages of Encapsulation Protection

Consistency

Allows change

Page 28: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

InheritanceA class which is a subtype of a more general

class is said to be inherited from it.

The sub-class inherits the base class’ data members and member functions

Page 29: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Inheritance (Cont’d)A sub-class has all data members of its base-

class plus its own

A sub-class has all member functions of its base class (with changes) plus its own

Inheritance is meant to implement sub-typing (don’t abuse it)

Page 30: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Inheritance Examples

Base Class Derived Classes

Student CommuterStudent ResidentStudent

Shape Circle Triangle Rectangle

Loan CarLoan HomeImprovementLoan MortgageLoan

Page 31: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

University community members

31

Employee

CommunityMember

Student

Faculty Staff

Administrator Teacher

Page 32: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Abstraction Management of complexity Hierarchical classification:

is-a relationship: inheritancehas-a relationship: containment

Page 33: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Abstraction Cont’dOne of the chief advantages of object-oriented

programming is the idea that programmers can essentially focus on the “big picture” and ignore specific details regarding the inner-workings of an object. This concept is called abstraction.

Page 34: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Polymorphism One interface

Multiple implementations

Inheritance

Method overloading

Page 35: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Polymorphism (Cont’d)Polymorphism describes how

programmers write methods to do some general purpose function.

Different objects might perform polymorphic methods differently.

Page 36: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

What is a good class ?A class abstracts objects

A class should be non-trivial in the context of the program (has data structures and operations different from other classes)

Page 37: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

MotivationVariables objectsTypes classes

Procedural programming: Low-level, closer to hardware More intuitive, less abstract More ‘action’ oriented Focus on ‘action’, ‘procedure’, ‘method’ Procedure-oriented

Object-oriented programming:

High-level More abstract Focus on ‘what to do’ not on ‘how to do’

In the implementation of OOP, we still need sound ‘procedure programming’ skills!

Page 38: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

int main(){ int x,y,z; int a,b,c;a=f1(x); b=f2(y);

c=f3(z);…}

int f1(){}int f2(){}int f3(){}

int main(){ A a; B b; C c;

a.f1(); b.f2(); c.f3(); …}

Class A{Int x;Int f1();}

Class B{Int y;Int f2()}

Class C{Int z;Int f3();}

Procedural programming: Object oriented programming: A sequence of ‘procedures’ A sequence of ‘objects’!

Page 39: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Object-oriented modeling and design

Page 40: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

IntroductionIt is a new way of thinking about problems

using models based on real world concepts.

The basic construct is object which combines both data structure and behavior in a single entity.

Rambaugh presents an object oriented software development methodology, the Object Modeling Technique (OMT) which extends from analysis through design to implementation.

Page 41: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

What is object-oriented?

41

Software is organized as a collection of discrete objects that incorporate both data structure and behavior.

In general it includes- identity, classification, polymorphism and inheritance.

Object Oriented Programming Language = Object Based Programming Language(e.g.

'83 Ada a Modula-2,C++and Java,etc.) + Inheritance + Dynamic Binding

Page 42: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Identity

42

Identity means that data is organized into discrete, distinguishable entities called objects.

Objects can be concrete or conceptual.

In real world an object simply exist but within a programming language each object has a unique handle by which it can be uniquely referenced.

The handle can be implemented by address, array index or unique value of an attribute.

Page 43: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Classification

43

It means that objects with same data structure (attribute) and behavior (operations) are grouped into a class.

A class is an abstraction that describes important properties and ignores the rest.

Page 44: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Polymorphism

44

It means that the same operation (i.e. action or transformation that the object performs) may behave differently on different classes.

Specific implementation of an operation by a certain class is called a method.

Page 45: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Inheritance

45

It is the sharing of attributes and operations among classes based on a hierarchical relationship.

Subclasses can be formed from broadly defined class.

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

Page 46: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Object-Oriented Development?

46

The theme is the identification and organization of application concepts rather than final representation in a prog. Language.

OOD approach encourages software developers to work and think in terms of the application domain through most of the software engineering life cycle.

It is a conceptual process independent of a programming language until the final stage.

Page 47: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Object-Oriented Methodology

47

Stages.

Analysis

System design

Object design

Implementation

Page 48: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

3 Models

48

Object Model

Dynamic model

Functional model

Page 49: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Object Model

49

Describes basic structure of objects and their relationship.

Contains object diagram.

Object diagram is a graph whose nodes are object classes (Classes) and whose arcs are relationships among classes.

Page 50: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Dynamic model

50

Describes the aspects of a system that change over time.

It specifies and implement control aspects of a system.

Contains state diagram.

State diagram is a graph whose nodes are states and whose arcs are data-flows.

Page 51: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Functional Model

51

Describes data value transformation within a system.

Contains data flow diagram.

Data Flow Diagram is a graph whose nodes are processes and whose arcs are data flows.

Page 52: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Object-Oriented Concepts

52

AbstractionEncapsulationCombining data and behaviorSharingObject structure, not Procedure StructureSynergy

Page 53: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

On completion of the class, a student should be able:

•To prepare object-oriented design for small/medium scale problems

• To demonstrate the differences between traditional imperative design and object-oriented design

• To explain class structures as fundamental, modular building blocks

• To understand the role of inheritance, polymorphism, dynamic binding and generic structures in building reusable code

• To write small/medium scale c++ programs with simple graphical user interface

• To use classes written by other programmers when constructing their systems

Page 54: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Summary

What is Object Oriented Programming?

Object-oriented programming is a method of implementation in which programs are organized as cooperative collections of objects, each of which represents an instance of some class, and whose classes are all members of one or more hierarchy of classes united via inheritance relationships

Page 55: Title:Object Oriented Systems Paper Code :CA - 205 Course:MCA Faculty:Ms. Charu Sharma Vikrant Gupta Course Description:

Expected Result

100%