Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Paradigms(Model) Two Paradigms: – Procedural Programming Paradigm – Object Oriented Paradigm Objective of OO approach is to eliminate some.

Similar presentations


Presentation on theme: "Programming Paradigms(Model) Two Paradigms: – Procedural Programming Paradigm – Object Oriented Paradigm Objective of OO approach is to eliminate some."— Presentation transcript:

1 Programming Paradigms(Model) Two Paradigms: – Procedural Programming Paradigm – Object Oriented Paradigm Objective of OO approach is to eliminate some of the flaws encountered in procedural approach. Flaws: Concentrated on logical organization of the code. Data (global) is allowed to move freely in the system. There is a chance of unintentional tampering of the data by the functions which access it. This data is not related to any one function (global data)

2 OOP Paradigm OOP treats data as critical element Does not allow to move freely in the system. It ties data closely to the function that operates on it. Protects it from unintentional tampering. Object=data+method Data Method

3 OOP Paradigm OOP allows us to decompose a problem into number of entities called “objects”. (Procedural paradigm decompose a problem into number of functions ) Then build data and functions (methods) around these entities. The combination of data and method make up OBJECT. The data of an object can be accessed only by the methods associated with that object. However methods of one object can access the methods of other objects.

4 Features of OOP Paradigm Emphasis is on data rather than procedure. Programs are divided into objects. Data structure characterize the objects. Methods that operate on the data of an object are tied together in the data structure(CAR example) Data is hidden and cannot be accessed by the external functions Objects may communicate with each other through methods.

5 Define: Object Oriented Programming Object Oriented Programming is an approach that provides a way of modularizing program by creating portioned memory area for both data and functions, that can be used as templates for creating copies of such modules on demand. Object oriented programming encourage you to decompose a problem into its constituent parts. Each component becomes a self-contained object that contains its own instructions and data that relate to that object. In this way, complexity is reduced and the programmer can manage larger program.

6

7 Object Oriented Programming Model Abstraction Encapsulation Inheritance Polymorphism

8 Abstraction It is essential element of object oriented programming. It is the act of representing essential features without including details. Human manages complexity through abstraction. Abstraction can be managed through hierarchical classification.

9 Hierarchical Classification CAR Car_EngineBreaking System Steering Audio System A/C Gear System FM CD Player

10 CAR_Engine Status:on/off Speed Start() Stop() Increase_speed() Decrease_speed() AudioSystem Status: on/off Volume (sound). Power. Start() Stop() Pause() Open_CD_Drive() Close_CD_Drive() Increase_Volume() Decrease_Volume() Start_FM() Stop_FM() select_Channel()

11 Encapsulation Encapsulation is the mechanism that binds together code and the data it manipulates. It keeps both safe from outside interference and misuse. It acts as a protective wrapper that prevents the code and data from being arbitrarily accessed by other code outside the wrapper. [Discuss by using procedural paradigm how car can be implemented and compare with OOP paradigm]

12 Encapsulation This same idea can be applied to programming. The power of encapsulated code is that everyone knows how to access it and thus can use it regardless of the implementation details- and without fear of unexpected side effects. In C++, the basis of encapsulation is CLASS. A class defines the structure and behavior (data and code) that will be shared by set of objects. Each object of a given class contains the structure and behavior defined by the class. Objects are referred as “instance of a class” The CLASS is a logical (blue print) construct and an OBJECT has physical reality.

13 Classes When we create a class, we specify the code (method) and data (variables). The methods and data are collectively called members of a class. We refer them as me “member variables or instance variables”. The code/method is referred as “member method or just a method”.


Download ppt "Programming Paradigms(Model) Two Paradigms: – Procedural Programming Paradigm – Object Oriented Paradigm Objective of OO approach is to eliminate some."

Similar presentations


Ads by Google