MAITRAYEE MUKERJI Object Oriented Programming in C++

Slides:



Advertisements
Similar presentations
Chapter 10: Designing Databases
Advertisements

Data Structures.
4. Object-Oriented Programming Procedural programming Structs and objects Object-oriented programming Concepts and terminology Related keywords.
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
Database Systems: Design, Implementation, and Management Tenth Edition
Overview of Data Structures and Algorithms
1 OBJECT-ORIENTED CONCEPTS. 2 What is an object?  An object is a software entity that mirrors the real world in some way.  A software object in OOP.
Abstraction Lecture-4. ADT example: London Underground Map.
Solutions to Review Questions. 4.1 Define object, class and instance. The UML Glossary gives these definitions: Object: an instance of a class. Class:
7M701 1 Software Engineering Object-oriented Design Sommerville, Ian (2001) Software Engineering, 6 th edition: Chapter 12 )
Design The goal is to design a modular solution, using the techniques of: Decomposition Abstraction Encapsulation In Object Oriented Programming this is.
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
Marcelo Santos – OOAD-CDT309, Spring 2008, IDE-MdH 1 Object-Oriented Analysis and Design - CDT309 Period 4, Spring 2008 Object-oriented concepts.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
Object Oriented Concepts. Movement toward Objects Instead of data-oriented or process-oriented Analysis, many firms are now moving to object-oriented.
Distribution of Marks Internal Sessional Evaluation Assignments – 10 Quizzes – 10 Class Participation Attendence – 5 Mid – Term Test – 25 External Evaluation.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
1 INTRODUCTION TO OOP Objective: Know the difference between functional programming and OOP Know basic terminology in OOP Know the importance of OOP Know.
BACS 287 Basics of Object-Oriented Programming 1.
 Computer Science 1MD3 Introduction to Programming Michael Liut Ming Quan Fu Brandon.
Object Oriented Programming Development
Welcome to OBJECT ORIENTED PROGRAMMIN Date: 10/09/2014 Prepared By Prepared By : VINAY ALEXANDER PGT(CS) KV jhagrakhand.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
SOFTWARE DESIGN Design Concepts Design is a meaningful engineering representation of something that is to be built It can be traced to a customer’s requirements.
Prepared By Ms.R.K.Dharme Head Computer Department.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
DataBase Management System What is DBMS Purpose of DBMS Data Abstraction Data Definition Language Data Manipulation Language Data Models Data Keys Relationships.
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.
 Computer Science 1MD3 Introduction to Programming Michael Liut Ming Quan Fu Brandon.
ITEC 3220A Using and Designing Database Systems Instructor: Prof Z. Yang Course Website: 3220a.htm
Elements of OO Abstraction Encapsulation Modularity Hierarchy: Inheritance & Aggregation 4 major/essential elements3 minor/helpful elements Typing Concurrency.
SOFTWARE DESIGN. INTRODUCTION There are 3 distinct types of activities in design 1.External design 2.Architectural design 3.Detailed design Architectural.
Learners Support Publications Object Oriented Programming.
CSC 131 Fall 2006 Lecture # 6 Object-Oriented Concepts.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
Salman Marvasti Sharif University of Technology Winter 2015.
Dr D. Greer, Queens University Belfast )Chapter Six 1 Software Engineering Chapter Six Software Design Quality Learning Outcomes.
OOP (Object Oriented Programming) Lecture 1. Why a new paradigm is needed? Complexity Five attributes of complex systems –Frequently, complexity takes.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)
Copyright 2006 Oxford Consulting, Ltd1 January Introduction to C++ Programming is taking A problem Find the area of a rectangle A set of data.
Next Back MAP MAP F-1 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All.
Object Oriented Programming. OOP  The fundamental idea behind object-oriented programming is:  The real world consists of objects. Computer programs.
Lecture 2 Object-oriented programming. Definitions of OOP OOP is a programming paradigm, which utilizes encapsulation, inheritance and polymorphism. (From.
OOPS CONCEPT.  OOPS  Benefits of OOPs  OOPs Principles  Class  Object Objectives.
Object Oriented Paradigm OOP’s. Problems with Structured Programming As programs grow ever larger and more complex, even the structured programming approach.
Introduction to Object Oriented Programming Lecture-3.
Basic Characteristics of Object-Oriented Systems
MAITRAYEE MUKERJI Object Oriented Programming in C++: Hierarchy / Inheritance.
Welcome to OBJECT ORIENTED PROGRAMMING Prepared By Prepared By : VINAY ALEXANDER PGT(CS) KV jhagrakhand.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
Object Oriented Programming
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING
Sachin Malhotra Saurabh Choudhary
The Movement To Objects
CHAPTER 5 GENERAL OOP CONCEPTS.
Classes and OOP.
Programming in Java Sachin Malhotra, Chairperson, PGDM-IT, IMS Ghaziabad Saurabh Chaudhary, Dean, Academics, IMS Ghaziabad.
Chapter 8: Data Abstractions
CSC 205 – Java Programming II
The Object model The Evolution of the Object Model Elements of the Object Model Applying the Object Model.
ITEC 3220A Using and Designing Database Systems
Introduction to Data Structure
Object-Oriented PHP (1)
Agenda Software development (SD) & Software development methodologies (SDM) Orthogonal views of the software OOSD Methodology Why an Object Orientation?
Object Oriented Programming (OOP)- Assist. Prof. Dr
Presentation transcript:

MAITRAYEE MUKERJI Object Oriented Programming in C++

Issues in Procedural/ Structured Languages Procedural languages: Pascal, Fortran, and C Large programs are usually divided into modules and functions Issues  Unrestricted access to global data  Poor modeling of the real world

Issues in Procedural/ Structured Languages Unrestricted access and difficult to maintain data integrity  Data normally does not have an owner  Functions, the building blocks are usually defined global  Many functions can work on the same data Data Function 1 Function 2 Function 3

Contd.

Issues in Procedural Languages Resource de-allocation does not take place automatically : memory, open files, open database and network connections – memory leaks etc. Insufficient support for abstractions / inadequate modeling of real world entity  In procedural languages, data is separated from the functions that operate on the data

Stack & Queue Functions struct Stack {int top; char*data; } struct Queue {int front, rear; char*data } Insert() Pop (); Delete() Push(); Issues in Procedural Languages Global Functions

HORSE EAGLE struct Horse {int age; intweight; intcolor; } gallop() canter() struct Eagle {int age; intweight; intwingspan; } fly() hunt() Issues in Procedural Languages Eagle can gallop Horse can fly

Object An object can be defined as a tangible entity that exhibits some well-defined behavior (Booch et. al., 2007) Complex real-world objects have both attributes and behaviour

Object Attributes / Characteristics  Attributes in the real world are equivalent to data in a program: they have a certain specific values  Nouns Behaviour / Response to some stimulus  Behaviour is like a function: one calls a function to do something (display the inventory, for example) and it does it.  Verbs

Example Student  Name, Roll No, DoB, Enrolled Prgm, Year of Enrollment  AddName(), DeleteName(), UpdateName() Shape  Number of Sides, No of Vertices, List of adjacent sides  Draw(), Color(), Resize()

Objects - Examples Data Storage Constructs  Customised arrays, stacks, linked lists, trees Human entities  Employees, Students, Customers, Sale persons Collection of data  Inventory, Dictionary, Personnel file Physical Objects:  Automobiles in a traffic-flow simulation  Electrical components in a circuit-design program  Countries in an economic model  Aircraft in an air traffic control system Elements of the computer-user environment  Windows, Menus, Graphic Objects (lines, rectangle etc).  Mouse, Keyboard, Printer

Object Oriented Approach Unifying concept in computer science Any problem is conceptualized in terms of objects Look at a programming problem in terms of objects instead of functions Classes and objects as building blocks instead of algorithms  Better modeling of real world entities

Object Oriented Approach Procedural Approach Vs Object Oriented Approach  Computing and Printing a Paycheck  Sorting a list of names

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 a hierarchy of classes united via inheritance relationships (Booch et. al. 2007).

Contd. There are three important parts to this definition:  Object-oriented programming uses objects, not algorithms, as its fundamental logical building blocks  Each object is an instance of some class; and  Classes may be related to one another via inheritance relationships

Object Oriented Language A language is object-oriented if and only if it satisfies the following requirements:  It supports objects that are data abstractions with an interface of named operations and a hidden local state.  Objects have an associated type [class].  Types [classes] may inherit attributes from super types [superclasses]. ( Cardelli and Wegner, cited from Booch et. Al. 2007) Such languages support inheritance i.e. it is possible to express “is a” relationships among types

Object Oriented Language Combine into a single unit both data and the functions that operate on that data. Such a unit is called an object. An object’s functions, called member functions in C++, typically provide the only way to access its data. If you want to read a data item in an object, you call a member function in the object. It will access the data and return the value to you. You can’t access the data directly.

Contd. If you want to modify the data in an object, you know exactly what functions interact with it: the member functions in the object. No other functions can access the data. This simplifies writing, debugging, and maintaining the program. Data and its functions are said to be encapsulated into a single entity. Data encapsulation and data hiding are key terms in the description of object-oriented languages. The data is hidden, so it is safe from accidental alteration.

Example

Key Features of Object Oriented Language Four major elements:  Abstraction  Encapsulation  Modularity  Hierarchy Three minor elements:  Typing  Concurrency  Persistence

Key Features … An abstraction denotes the essential characteristics of an object that distinguish it from all other kinds of objects and thus provide crisply defined conceptual boundaries, relative to the perspective of the viewer. Encapsulation is the process of compartmentalizing the elements of an abstraction that constitute its structure and behavior; encapsulation serves to separate the contractual interface of an abstraction and its implementation. Modularity is the property of a system that has been decomposed into a set of cohesive and loosely coupled modules.

Key Features Hierarchy is a ranking or ordering of abstractions. Typing is the enforcement of the class of an object, such that objects of different types may not be interchanged or, at the most, may be interchanged only in very restricted ways. Concurrency is the property that distinguishes an active object from one that is not active. Persistence is the property of an object through which its existence transcends time and/or space.

C++ Object Oriented Features

Contd.

References Chapter 2 and Appendix A: Object Oriented Programming Language from Booch et. al. prev689/ /1996/talks/tbooch.htm prev689/ /1996/talks/tbooch.htm apers/quillin.htm apers/quillin.htm