1 / 25

CHAPTER 2

CHAPTER 2. OBJECT ORIENTED PROGRAMMING. INTRODUCTION.

rhoswen
Download Presentation

CHAPTER 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CHAPTER2 OBJECT ORIENTED PROGRAMMING

  2. INTRODUCTION This chapter begins with brief discussion of various Programming paradigms that C++ supports i.e., procedural programming style, object based programming style and object oriented programming style. This is followed by detailed discussion of object oriented programming and its implementation. All this shall help you appreciate OOP style and its advantages over other programming methodologies.

  3. What is a Programming Paradigm What is a Programming Paradigm A Programming Paradigm defines the methodology of designing and implementing programs using the key features and building blocks of a programming language.

  4. Procedural Programming Procedural programming paradigm separates the functions and the data manipulated by them. This leads to many problems when it comes to extending the software or maintaining the software. • Procedural Programming is susceptible to design changes. • Procedural Programming leads to increase time and cost overheads during design changes.

  5. Object Based Programming Object based programming is a newer paradigm that implements some features of object oriented programming but not all. In object based programming, data and its associated meaningful functions are enclosed in one single entity a class. Classes enforce information hiding and abstraction thereby separating the implementation details and the uses interface.

  6. [For instance, you can consider a calculator, its interface would include a small display screen and a few buttons that is available to the user and implementation details i.e. how actual calculations are taking place are hidden from user.]

  7. Object based programming localizes the implementation details. • Object based programming is subject of Object Oriented programming.

  8. Advantages of Object Based Programming • It overcomes most shortcomings of procedural programming, • It localizes changes and hides implementation details from user, • It supports user-defined types, • Implements information hiding and abstraction etc.

  9. Limitations However, object based programming suffers from a major limitation and that is its inability to represent real world relationships that exist among object. For example, both car and truck are vehicles. This can not be represented in object based programming as it does not support inheritance.

  10. Object Oriented Programming The object oriented programming paradigm is superset of object based programming. It offers all the features of object based programming and overcomes its limitation by implementing inheritance.

  11. What is an OBJECT? Object is an identifiable entity with some characteristics and behaviour. What is a CLASS ? A class is a group of objects that share common properties and relationships.

  12. Function 1 Object 1 Object 2 All data is openly available to all functions in the program Data 1 Properties Behaviour Properties Behaviour Function 2 Data 2 Function 3 Data and functions enclosed within objects. New objects communicate with one another.

  13. BASIC CONCEPTS OFOOP These general concepts of OOP are given below: • Data Abstraction • Data Encapsulation • Modularity • Inheritance • Polymorphism

  14. Data Abstraction Abstraction refers to the act of representing essential features without including the background details or explanations.

  15. What is encapsulation ? The wrapping up of data and operations / functions (that operate on the data) into a single unit (called class) is known as Encapsulation.

  16. Data Object Member Functions Data Data Member Functions Member Functions Object Object

  17. Modularity The act of partitioning a program into individual components is called modularity. The justification for partitioning a program is that • it reduces its complexity to some degree and • it creates a number of well-defined, documented boundaries within the program

  18. What is a Modularity ? Modularity is the property of a system that has been decomposed into a set of cohesive and loosely coupled modules.

  19. Inheritance Inheritance is the capability of one class of things to inherit capabilities or properties from another class.

  20. Vehicles Automobiles (Motor driven) Pulled Vehicles Car Bus Cart Rickshaw Property Inheritance

  21. Polymorphism Polymorphism is the ability for a message or data to be processed in more than one form.

  22. Shape Area Circle Area (circle) Triangle Area (triangle) Rectangle Area (rectangle) Polymorphism

  23. ADVANTAGES of OOP • Re-use of code. • Ease of comprehension. • Ease of fabrication and maintenance. • Easy redesign and extension.

  24. DISADVANTAGES of OOP • With OOP, classes tend be overly generalized. • The relations among classes become artificial at times. • The OOP programs’ design is tricky. • Also one need to do proper planning and proper design for OOP programming. • To program with OOP, programmer need proper skills such as design skills, programming skills, thinking in terms of objects etc.

  25. Thanking You The End

More Related