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

Post on 18-Dec-2015

219 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

Transcript

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:  

Object Oriented Programming

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

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“.

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.

Problem Description“ customers are allowed to have different

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

Procedural Approach

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

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

};

Procedural Approach cont’dFocus is on procedures

All data is shared: no protection

More difficult to modify

Hard to manage complexity

Procedural vs. Object-Oriented

Procedural

Withdraw, deposit, transfer

Object Oriented

Customer, money, account

Mapping the world to software

Objects in the problem domain are mapped to objects in software

011101

10011

11101

0110100

11010

010101

1110101

10101

Object OrientedData and operations are grouped together

Account

Deposit

Withdrawl

Transfer

Interface:

Set of available operations

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)

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

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

Properties: ● encapsulation ● inheritance ● polymorphism

Objects and Classes

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

Daria Jane BrittanyJodie

girlclassobject

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

Objects and Classes (cont’d)

Class BankAccount

BalanceInterestYTDOwnerAccount_number

Balance 500InterestYTDOwner Account_number

Balance 10,000InterestYTDOwner Account_number

Operations

MakeDesposit

Transfer

WithDraw

GetBalance

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

InstantiationAn Object is instantiated from a Class

BankAccount myAccount;

myAccount = new BankAccount;

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

Classification

Mammal

Rodent Primate Cats

Reptile

Animal

Squirel RabbitMouse

Classification

Checking Account

Value First Select Access First Interest

Savings Account

Account

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.

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.

Data Encapsulation

class Account {

public:

float withdraw();

void deposit(float amount);

private:

float balance;

);

Advantages of Encapsulation Protection

Consistency

Allows change

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

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)

Inheritance Examples

Base Class Derived Classes

Student CommuterStudent ResidentStudent

Shape Circle Triangle Rectangle

Loan CarLoan HomeImprovementLoan MortgageLoan

University community members

31

Employee

CommunityMember

Student

Faculty Staff

Administrator Teacher

Abstraction Management of complexity Hierarchical classification:

is-a relationship: inheritancehas-a relationship: containment

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.

Polymorphism One interface

Multiple implementations

Inheritance

Method overloading

Polymorphism (Cont’d)Polymorphism describes how

programmers write methods to do some general purpose function.

Different objects might perform polymorphic methods differently.

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)

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!

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’!

Object-oriented modeling and design

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.

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

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.

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.

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.

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.

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.

Object-Oriented Methodology

47

Stages.

Analysis

System design

Object design

Implementation

3 Models

48

Object Model

Dynamic model

Functional model

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.

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.

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.

Object-Oriented Concepts

52

AbstractionEncapsulationCombining data and behaviorSharingObject structure, not Procedure StructureSynergy

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

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

Expected Result

100%

top related