Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations

Presentation on theme: "Understand and appreciate Object Oriented Programming (OOP) Objects are self-contained modules or subroutines that contain data as well as the functions."— Presentation transcript:

1 Understand and appreciate Object Oriented Programming (OOP) Objects are self-contained modules or subroutines that contain data as well as the functions necessary to manipulate that data within the same module or subroutine. In object-oriented programming subroutines as well as data are locally defined in objects. The difference affects the way a programmer goes about writing a program as well as how information is represented and activated in a computer. Consequently, object-oriented programming opens a new perspective for the art of programming as well as for basic computer architecture.

2 Object Oriented Programming is becoming (or has already become?) a buzz word in the IT-Industry. Object Oriented Programming is not just programming or coding. Its a way of thinking! Its not just a collection of new programs or programming languages, but it is a new thought process that it generated in the Object-Oriented thinker, to make the life of the programmers easier and better by structuring information in a computer. A designer is always face with the choice of building the system based on the data or on actions. Object oriented approach lays more stress on data than on actions. Any successful system inevitably undergoes numerous changes over its lifetime. The quality of architecture is depending on how well the architecture adapts the changes and not on how easily it was done. In this criteria objects have an edge over functions.

3 As a system evolves, its tasks may change dramatically. But the classes of data they manipulate remain persistent, atleast if viewed from sufficient level of abstraction. This helps in maintaining continuity. The top-down method was quite successful as advocated in structured programming, but it suffers from many flaws like: -The evolutionary nature of the software systems is neglected. -Real systems have no top functions. -Using the functions means data structure is neglected. -Does not promote reusability.

4 Object-Oriented programming is an approach that provides a way of modularizing programs by creating partitioned memory area for both data and functions that can be used as templates for creating copies of such modules on demand. Some of the features of object-oriented paradigm are: -Emphasis is on data rather than procedure. -Programs are divided into what are known as Objects. -Data structures are designed such that they characterize the objects.

5 Methods that operate on the data of an object are tied together in the data structure. -Data is hidden and cannot be accessed by external functions. -Objects may communicate with each other through methods. -New data and methods can be easily added whenever necessary. -Follows bottom-up approach in program design.

6 Data Abstraction and Encapsulation Process of defining data and relational functions as a single entity using the keyword class. ADT (Abstract Data Type) usually these ADTs are bundled with not only the data components, but also such functions, that can act upon the data components. Functions Acting upon the Data Components. Data Components Abstract Data Type User cant directly use this part User interfaces with this part.

7 An ADT is a collection of data (variables) and the functions that can manipulate the variables, and an OBJECT is created from an ADT. The functions that are in an ADT defined the operations that can be performed on an ADT. And an ADT is often referred to as Class. The functions that define the operations that can be performed on the variables are called methods. Class-ADT called otherwise Object-An instance of an ADT Method-The functions that operate upon the ADTs data

8 The term Data Encapsulation involves the logical binding of data with a specific operation. For example, in a procedural language, a local function variable is tied specifically to the logical operation of that function. The data encapsulated in the sense that it is not global and accessible to the entire program, only one small portion of it. Data encapsulation then automatically implies data hiding, or protecting. The wrapping up of data and methods into a single unit (called class) is known as encapsulation. The data is not accessible to the outside world and only those methods, which are wrapped in the class, can access it. This insulation of the data from direct access by the program is called data hiding.

9 Inheritance Inheritance is a mechanism of deriving a new class from an existing class. Inheritance in OOP allows a class to inherit properties from a class of objects. The parent class serves as a pattern for the derived class and can be altered in several ways. If an object inherits its attributes from a single parent, it is called Single Inheritance. If an object inherits its attributes from multiple parents, it is called Multiple Inheritance. Inheritance encourages the reuse of code since child classes are extensions of parent classes.

10 When, in real world, a person has a child, the Child gets the features of its parents and acquires the richness. The same way, when an ADT has a child, the child acquires the features of its parent. Also, just us with us, the child ADT also has capabilities to add more riches to itself apart from those acquired from the parent. This feature is called Inheritance.

11 Polymorphism Different objects behave differently to the same function calls or operations. This is polymorphism. Polymorphism is the capability of a function or method to react differently in different objects for the same message received. Polymorphism helps us reduce the number of functions that we have to remember. Polymorphism encourages extendibility of existing code. Polymorphism allows each subclass object to respond to the message format in a manner appropriate to its definition.

12 Polymorphism is two types 1. Compile time Polymorphism (i) Function overloading (ii) Operator overloading 2. Runtime Polymorphism Implemented using virtual functions and pointers. Example: We have three objects called Line, Circle, and Rectangle, and all these objects have an operation called Draw, who has the obvious job to do. However, when we send a Draw message to Line, Draw draws a line, when I send it to a Circle, it draws a circle and so on.

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

Similar presentations

Ads by Google