EC-241 OBJECT-ORIENTED PROGRAMMING (OOP)

Slides:



Advertisements
Similar presentations
Understand and appreciate Object Oriented Programming (OOP) Objects are self-contained modules or subroutines that contain data as well as the functions.
Advertisements

Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
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.
Chapter 1 OO using C++. Abstract Data Types Before we begin we should know how to accomplish the goal of the program We should know all the input and.
OOP - Object Oriented Programming Object Oriented Programming is an approach to programming that was developed to make large programs easier to manage.
OBJECT ORIENTED PROGRAMMING M Taimoor Khan
Unified Modeling Language
INTRODUCTION T.Najah Al_Subaie Kingdom of Saudi Arabia Prince Norah bint Abdul Rahman University College of Computer Since and Information System CS240.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Lecture 9 Concepts of Programming Languages
1 Introduction to C++ Programming Concept Basic C++ C++ Extension from C.
CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++
Abstract Data Types and Encapsulation Concepts
C++ fundamentals.
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
COMPUTER PROGRAMMING. Introduction to C++ History Merges notions from Smalltalk and notions from C The class concept was borrowed from Simular67 Developed.
Introduction To System Analysis and design
Programming Languages and Paradigms Object-Oriented Programming.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to Classes and Objects Outline Introduction Classes, Objects, Member Functions and Data.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
Chapter 11: Inheritance and Composition. Objectives In this chapter, you will: – Learn about inheritance – Learn about derived and base classes – Redefine.
Introduction to Object-oriented programming and software development Lecture 1.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
Object Oriented Design and Programming Alan Goude Room: Sheaf 9323.
Rossella Lau Lecture 1, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 1: Introduction What this course is about:
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 24P. 1Winter Quarter C++ Lecture 24.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
1 Object-Oriented Programming Using C++ CLASS 1. 2 Review of Syllabus Catalog Description –An introduction to object oriented programming techniques using.
Data Structures Using C++ 2E1 Inheritance An “is-a” relationship –Example: “every employee is a person” Allows new class creation from existing classes.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
Learners Support Publications Object Oriented Programming.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
Object-Oriented Programming Chapter Chapter
1 OOP - An Introduction ISQS 6337 John R. Durrett.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 12 Object-Oriented Programming Starting Out with Games & Graphics.
ISBN Object-Oriented Programming Chapter Chapter
OOP Review CS 124.
1 Copyright © 1998 by Addison Wesley Longman, Inc. Chapter 10 Abstraction - The concept of abstraction is fundamental in programming - Nearly all programming.
1 CSE Programming in C++. 2 Overview Sign roster list Syllabus and Course Policies Introduction to C++ About Lab 1 Fill Questionnaire.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Chapter 11: Inheritance and Composition. Introduction Two common ways to relate two classes in a meaningful way are: – Inheritance (“is-a” relationship)
Object Oriented Programming. OOP  The fundamental idea behind object-oriented programming is:  The real world consists of objects. Computer programs.
OOPS CONCEPT.  OOPS  Benefits of OOPs  OOPs Principles  Class  Object Objectives.
Object-Oriented Programming (OOP) and C++
Object Oriented Paradigm OOP’s. Problems with Structured Programming As programs grow ever larger and more complex, even the structured programming approach.
Structure A Data structure is a collection of variable which can be same or different types. You can refer to a structure as a single variable, and to.
1 n Object Oriented Programming. 2 Introduction n procedure-oriented programming consists of writing a list of instructions and organizing these instructions.
ISBN Chapter 12 Support for Object-Oriented Programming.
CPS120: Introduction to Computer Science Lecture 16A Object-Oriented Concepts.
MAITRAYEE MUKERJI Object Oriented Programming in C++
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING
Sachin Malhotra Saurabh Choudhary
Object-Oriented Programming (OOP) Lecture No. 45
About the Presentations
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Object-Orientated Programming
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
(5 - 1) Object-Oriented Programming (OOP) and C++
Lecture 9 Concepts of Programming Languages
Programming 1 (CS112) Dr. Mohamed Mostafa Zayed 1.
(5 - 1) Object-Oriented Programming (OOP) and C++
UNIT I OBJECT ORIENTED PROGRAMMING FUNDAMENTALS
Chapter 11: Inheritance and Composition
CPS120: Introduction to Computer Science
Object Oriented Programming (OOP)- Assist. Prof. Dr
Lecture 9 Concepts of Programming Languages
Presentation transcript:

EC-241 OBJECT-ORIENTED PROGRAMMING (OOP) LECTURE 1 Bushra Riaz

COURSE OUTLINE Course Code: EC-241 Credits: 4 (3,1) Prerequisites: EC-111 Algorithms and Computing Text Book C++ How to Program, Deitel and Deitel, 7th Edition, ISBN-10: 0-13-611726-0, Prentice Hall, 2009 References Object Oriented Programming with C++, Robert Lafore, 4th Edition, ISBN-10: 0-672-32308-7, Sams, 2002 The complete Reference C++, Herber Schildt, 3rd Edition The Unified Modeling Language User Guide, Booch, Rumbaugh, Addison- Wesley, ISBN-10: 0-321-26797-4, 2nd Edition, 2005

COURSE OUTLINE Introduction: Procedural versus Object Oriented Programming (OOP), characteristics of OOP, advantages of OOP, Abstract Data Types (ADT), information hiding, encapsulation. Classes and Objects: Classes, objects, access specifiers, data members, member functions, properties, getters and setters, object aggregation. Constructors and Destructors: Default constructors, overloaded constructors, copy constructor, conversion constructor, shallow vs. deep copy.

COURSE OUTLINE Static Members: Static data members and static member functions. Generic Programming and Overloading: Function overloading, operator overloading, templates, C++ standard template library (STL). Dynamic memory management for objects: Pointers to objects, reference variables

COURSE OUTLINE Inheritance and Polymorphism: Inheritance, types of inheritance, derived classes, function overriding, dynamic binding, polymorphism, virtual functions. Streams and Files: Stream classes, File objects, File operations with streams. Object-Oriented Design: Introduction to Unified Modeling Language (UML).

Evaluation Methods: Assignments Quizzes Midterm exams Final Exam Lab Project

PROCEDURAL VS. OBJECT-ORIENTED LANGUAGES Procedural Language Views a program as a series of steps to be carried out E.g. C, FORTRAN, Pascal Object Oriented Language Views a program as a group of objects that have certain properties and can perform certain functions E.g. C++, Java, C#

PROCEDURAL VS. OBJECT-ORIENTED LANGUAGES Problems with Procedural Languages Cannot cope with very large project sizes Expensive software errors (e.g. air traffic control) Causes of Problems Unrestricted Access to Data Global data is allowed Access to data by multiple functions means many connections between functions Programs become difficult to understand, modify and maintain

PROCEDURAL VS. OBJECT-ORIENTED LANGUAGES Poor Modeling of Real World Things Real world things are integral collections of data and functions e.g. a car: has data (make, model etc.) and functions (acceleration) Procedural languages do not tie up data with functions

Example Procedural program 1. Gather ingredients Flour, butter, egg, sugar etc 2. preheat oven to 350 degree 3. beat eggs and butter 4. add sugar 5. mix 6. bake 10 mins

Example Object Oriented programing Model for an Object Properties List of ingridients, or set of data Methods List of actions or instructions

Example Object Oriented programing Baker { Properties (ingredients) Flour Butter Eggs Milk Cake pan Oven Methods (actions) Bake cookies Bake cake Bake pie } 1. Gather ingredients Flour, butter, egg, sugar etc 2. preheat oven to 350 degree 3. beat eggs and butter 4. add sugar 5. mix 6. bake 10 mins

THE PROCEDURAL PARADIGM Global Data Function

GOAL OF OOP Clearer, more reliable, more easily maintained programs More effective way of coping with program complexity

OBJECT-ORIENTED LANGUAGES Most widely used Largest programmer base Java Lacks certain features, e.g. multiple inheritance, pointers, templates Less powerful than C++ (but more safe, of course) C# Emerging

THE OO APPROACH The fundamental idea is to combine into a single unit both data and functions that operate on the data. Such a unit is called an “Object”. An object’s functions are called “member functions” in C++ And its data is called “ data members”.

THE OO APPROACH An object’s data is typically accessed through its member functions, i.e. it is hidden from accidental alteration Data and its function are said to be encapsulated into a single entity Data encapsulation and data hiding are key elements of object-oriented languages

THE OO APPROACH If you want to modify data in an object, you know exactly what functions interact with it (i.e. the member functions of the object). This simplifies writing, debugging, and maintaining the programs An OO program consists of a number of objects which communicate with each other’s member functions

THE OBJECT-ORIENTED PARADIGM Data Member Function object

CHARACTERISTICS OF OO LANGUAGES Objects Classes Encapsulation Inheritance Polymorphism and overloading

CLASSES Objects belong to classes A class and an object of that class has the same relationship as a data type and a variable All objects with the same characteristics (data and functions) constitute one class. A class serves only as a plan, or a template, or sketch- of a number of similar things It merely specifies what data and what functions will be included in objects of that class.

CLASSES Declaring a class doesn’t create any objects, just as mere existence of data type int doesn’t create any variables. A class is thus a description of a no. of similar objects. For instance, HUMAN is a class, and JOHN is its instance (object)

Encapsulation Information hiding Encapsulation is the mechanism that binds together code and the data it manipulates, and keep both safe from outside inteference and missuse Data Member Function object

INHERITANCE Derive other (sub-)classes from an existing class The original class is called the BASE CLASS; the others are DERIVED CLASSES Each class shares common characteristics with the class from which it was derived, and can also add its own modifications, additions. For instance, VEHICLE is a class from which CAR, TRUCK, BUS, MOTORCYCLE classes can be derived.

INHERITANCE Base class F Feature A Feature B Feature D Feature F Feature C Feature D Feature E Feature F Derived classes

POLYMORPHISM AND OVERLOADING Using operators or functions in different ways depending on what they are operating on is called polymorphism (lit. one thing with several distinct forms) Overloading is a special case of polymorphism, e.g. +, -, /, << etc.

C AND C++ C++ C

EXAMPLE PROGRAM IN C++ #include <iostream> using namespace std; int main() { cout<<“Every age has a language of its own\n”; return 0; }

PROGRAM EXPLANATION <iostream> using namespace std int main() This header supports C++ I/O operations. iostream is to C++ what stdio.h is to C using namespace std This tells the compiler to use the std name space std::cout This is the namespace in which the entire Standard C++ library is declared This is required when we use the names that are brought into the program by the processor directive #include<iostream> int main()

PROGRAM EXPLANATION cout Stream The Operator << An object Predefined in C++ to correspond with the “standard output stream” Stream An abstraction that refers to a flow of data The standard output stream normally flows to the screen The Operator << Directs the contents of the variable on its right to the object on its left.

INPUT WITH cin int main() { int ftemp; cout<<“Enter temperature in fahrenheit: “; cin>>ftemp; int ctemp=(ftemp-32)*5/9; cout<<“Equivalent in celsius is : “<<ctemp; cout<<endl; return 0; }