Object Oriented Paradigm OOP’s. Problems with Structured Programming As programs grow ever larger and more complex, even the structured programming approach.

Slides:



Advertisements
Similar presentations
When is Orientated Programming NOT? Mike Fitzpatrick.
Advertisements

Abstraction Lecture-4. ADT example: London Underground Map.
Computer Science Dept. Fall 2003 Object models Object models describe the system in terms of object classes An object class is an abstraction over a set.
Classes and Object- Oriented... tMyn1 Classes and Object-Oriented Programming The essence of object-oriented programming is that you write programs in.
Object-Oriented PHP (1)
7M701 1 Software Engineering Object-oriented Design Sommerville, Ian (2001) Software Engineering, 6 th edition: Chapter 12 )
INSTRUCTOR: SHIH-SHINH HUANG Windows Programming Using Java Chapter3: Introduction to Classes and Objects 1.
What is an object? Your dog, your desk, your television set, your bicycle. Real-world objects share two characteristics: They all have state and behavior;
Object-oriented Programming Concepts
Software Lifecycle A series of steps through which a software product progresses Lifetimes vary from days to months to years Consists of –people –overall.
ASP.NET Programming with C# and SQL Server First Edition
INTRODUCTION TO JAVA PROGRAMMING Chapter 1. What is Computer Programming?
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
C++ Classes & Object Oriented Programming. Object Oriented Programming  Programmer thinks about and defines the attributes and behavior of objects. 
Object-Oriented Analysis and Design
 Computer Science 1MD3 Introduction to Programming Michael Liut Ming Quan Fu Brandon.
CPT 140 Programming Constructs1 OBJECT ORIENTED TECHNOLOGY Terminology and Basic Concepts.
1 INTRODUCTION TO OOP Objective: Know the difference between functional programming and OOP Know basic terminology in OOP Know the importance of OOP Know.
Object Oriented Software Development
Using Classes Object-Oriented Programming Using C++ Second Edition 5.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
Object Oriented Programming Development
Chapter 5CSA 217 Design in Construction Chapter 5 1.
Introduction to Object-oriented programming and software development Lecture 1.
Object Oriented Programming Lecturer: Andreas P. Adi
An Object-Oriented Approach to Programming Logic and Design
Sadegh Aliakbary Sharif University of Technology Fall 2011.
CS 350 – Software Design The Object Paradigm – Chapter 1 If you were tasked to write code to access a description of shapes that were stored in a database.
Object Oriented Programming with JAVA Arash N. Kia AlZahra University Definitions – Part 1.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
JavaScript, Fourth Edition
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Chapter 6 Object-Oriented Java Script JavaScript, Third Edition.
Chapter 7 Objects and Classes 1 Fall 2012 CS2302: Programming Principles.
Object Oriented Programming Principles Lecturer: Kalamullah Ramli Electrical Engineering Dept. University of Indonesia Session-3.
SNPL1 Woochang Lim What (Variable) + How (Function) = Object Objects are the physical and conceptual things we find in the universe around us. Object-Oriented.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
1 Programming Paradigms Object Orientated Programming Paradigm (OOP)
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”
CSCI 1100/1202 April 1-3, Program Development The creation of software involves four basic activities: –establishing the requirements –creating.
CS451 - Lecture 2 1 CS451 Lecture 2: Introduction to Object Orientation Yugi Lee STB #555 (816) * Acknowledgement:
Designing Classes CS239 – Jan 26, Key points from yesterday’s lab  Enumerated types are abstract data types that define a set of values.  They.
Salman Marvasti Sharif University of Technology Winter 2015.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
Object-Oriented Programming (OOP) Lecture No. 2. Information Hiding ► Information is stored within the object ► It is hidden from the outside world ►
Programming Fundamentals. Topics to be covered Today Recursion Inline Functions Scope and Storage Class A simple class Constructor Destructor.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
OO in Context Lecture 13: Dolores Zage. Confused about OO Not alone, there is much confusion about OO many programs are claimed to be OO but are not really.
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
Learning OOP in PHP. What is OOP? OOP stands for Object Oriented Programming. OOP is a programming paradigm wherein you create “objects” to work with.
Object Oriented Programming. OOP  The fundamental idea behind object-oriented programming is:  The real world consists of objects. Computer programs.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
Object-Oriented Paradigm (OOP) Course Code: SE 101 Lecture No. 1.
Introduction to Object Oriented Programming Lecture-3.
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.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
MAITRAYEE MUKERJI Object Oriented Programming in C++
Introduction to Object Oriented Programming ( P ) Malik Jahan Khan 1.
Object Oriented Programming Development
Object Oriented Programming Spring Semester
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING
Concepts of Object Oriented Programming
C++.
Object-Oriented Programming
Object-Oriented Programming
BCA-II Object Oriented Programming using C++
Object Oriented Programming (OOP)- Assist. Prof. Dr
Presentation transcript:

Object Oriented Paradigm OOP’s

Problems with Structured Programming As programs grow ever larger and more complex, even the structured programming approach begins to show signs of strain. The project is too complex, the schedule slips, more programmers are required, complexity increases, costs increases like rocket, the schedule slips further, and disaster ensues. Analyzing the reasons for these failures reveals that there are weaknesses in the procedural paradigm itself. No matter how well the structured programming approach is implemented, large programs become excessively complex. 2University of Lahore Sargodha Campus

What are the reasons for these problems with procedural languages? There are two related problems. First, functions have unrestricted access to global data. Second, unrelated functions and data, the basis of the procedural paradigm, provide a poor model of the real world. e.g. these problems in the context of an inventory program. One important global data item in such a program is the collection of items in the inventory. Various functions access this data to input a new item, display an item, modify an item, and so on. 3University of Lahore Sargodha Campus

Unrestricted Access In a procedural program, for e.g. one written in C Language – There are two kinds of data. Local data is hidden inside a function, and is used exclusively by the function. – In the inventory program a display function might use local data to remember which item it was displaying. Local data is closely related to its function and is safe from modification by other functions. However, when two or more functions must access the same data—and this is true of the most important data in a program—then the data must be made global, as our collection of inventory items is. Global data can be accessed by any function in the program. The arrangement of local and global variables in a procedural program is shown. 4University of Lahore Sargodha Campus

5

In a large program, there are many functions and many global data items. The problem with the procedural paradigm is that this leads to an even larger number of potential connections between functions and data, as shown This large number of connections causes problems in several ways. First, it makes a program’s structure difficult to conceptualize. Second, it makes the program difficult to modify. A change made in a global data item may necessitate rewriting all the functions that access that item. 6University of Lahore Sargodha Campus

e.g. – in our inventory program, someone may decide that the product codes for the inventory items should be changed from 5 digits to 12 digits. This cause the need to change from a short to a long data type. – Now all the functions that operate on the data must be modified to deal with a long instead of a short. 7University of Lahore Sargodha Campus

8

Real-World Modeling – The second—and more important—problem with the procedural paradigm is that its arrangement of separate data and functions does a poor job of modeling things in the real world. – In the physical world we deal with objects such as people and cars. Such objects aren’t like data and they aren’t like functions. Complex real-world objects have both attributes and behavior. Attributes – Examples of attributes (sometimes called characteristics) are, for people, eye color and job title; and, for vehicles etc As it turns out, attributes in the real world are equivalent to data in a program: they have a certain specific values, such as blue or four. Behavior – Behavior is something a real-world object does in response to some stimulus. If anyone ask his boss for a raise, He/she will generally say yes/no. – If you apply the brakes in a car, it will generally stop. Saying something and stopping are examples of behavior. – Behavior is like a function: you call a function to do something and it does it. 9University of Lahore Sargodha Campus

The Object-Oriented Approach – The fundamental idea behind object-oriented languages is to 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. The data is hidden, so it is safe from accidental alteration. 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. 10University of Lahore Sargodha Campus

11University of Lahore Sargodha Campus

12University of Lahore Sargodha Campus

Reusability – Once a class has been written, created, and debugged, it can be distributed to other programmers for use in their own programs. – This is called reusability. It is similar to the way a library of functions in a procedural language can be incorporated into different programs. 13University of Lahore Sargodha Campus

14 What is Object Oriented Programming? An object is like a black box. The internal details are hidden. Identifying objects and assigning responsibilities to these objects. Objects communicate to other objects by sending messages. Messages are received by the methods of an object University of Lahore Sargodha Campus

15 What is an object? Tangible Things as a car, printer,... Roles as employee, boss,... Interactions as contract, sale,... Specifications as colour, shape, … University of Lahore Sargodha Campus

Object Oriented Programming Programmer who defines the attributes and behavior of objects Objects are modeled according to real-world entities Different approach from structure programming such as C language 16University of Lahore Sargodha Campus

Object Oriented Programming Object-oriented programming (OOP) – Encapsulates data (attributes) and functions (behavior) into packages named classes. Classes are user-defined types. – Data Members – Member Functions or Methods) 17University of Lahore Sargodha Campus

Reasons for OOP 1.Simplify programming 2.Interfaces Information hiding: – Implementation details hidden within classes themselves 3.Software reuse Class objects included as members of other classes 18University of Lahore Sargodha Campus

Classes in C++ A class definition begins with the keyword class. The body of the class is contained within a set of braces, { } ; (notice the semi-colon). class class_name { …. }; Class body (data member +Function) Any valid identifier 19University of Lahore Sargodha Campus

Classes C++ Within the body, the keywords private: and public: specify the access level of the members of the class. – Default is private Usually, the data members of a class are declared in the private: section of the class and the member functions are in public: section 20University of Lahore Sargodha Campus

Classes in C++ class class_name { private: … public: … }; Public members or methods private members or methods 21University of Lahore Sargodha Campus