01 What Is OOP
01 What Is OOP
01 What Is OOP
Home Assignment
What do you know about Programming? What is the role of Compiler & Interpreter in Programming? What is source code? What is Class? What is Object? What is Object Oriented Programming? C++ is structured or object oriented programming language. Justify this statement. Compare Structured and Object Oriented Programming. What is Encapsulation? What do you know about Data Abstraction? What is Inheritance? Also describe (in 2-3 line for each) types of inheritance. Why the Polymorphism is used in OOP's?
OOP Definition
Object-oriented programming is a way of implementation in which programs are organized as cooperative collections of objects, each of which represents an instance of some class, and those classes(categories) are all members of a hierarchy of classes united via inheritance relationships.''
The cost of software development & maintenance is increasing substantially as compared to the cost of the hardware of a computing system, but hardware technology is improved. This increasing cost in software & technological improvement in hardware demands a cost effective & more technical compatible programming paradigm. Software maintenance is the process of modifying or extending the capabilities of 5 the existing software.
Object
An object is like a black box. Its a material thing that can be seen or touched. The internal details of such things are hidden.
OO Programming 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
7
What is an object?
Tangible Things Roles Incidents Interactions Specifications as a car, printer, ... as employee, boss, ... as flight, overflow, ... as contract, sale, ... as colour, shape,
10
Object = Data + Methods or An object has the responsibility to know and the responsibility to do.
11
C++ or Java
12
Data Abstraction: The technique of creating new data types that are well
suited to an application or program known as data abstraction. It provides the ability to create user-defined data types which is also known as abstract data types (ADTs) . Inheritance:
It allows the extension and reuse of existing code without having to rewrite the code from scratch. Inheritance involves the creation of new classes (derived classes) from the existing ones (base classes). It enabling the creation of a hierarchy of classes , which gives the name of relationship: like: Parent Class & Child Class Relationship Base Class & Derived Class Relationship Super Class & Sub Class Relationship Two popular forms of inheritance are single and multiple inheritance. Single inheritance refers to deriving a class from a single base class 13
Structured Programming
Emphasis on algorithm rather than data Programs are divided into individual procedures that perform discrete tasks Procedures are independent of each other as far as possible Procedures have their own local data and processing logic Parameter passing facility between the procedures for information communication Controlled scope of data Introduction of the concepts of user defined data types Support for modular programming (used to break up a large program into manageable units), projects can be broken up into modules and programmed independently Scope of data items is further controlled across modules A rich set of control structures are available to further abstract the procedures
Limitations:
Co-ordination among multiple programmers is required for handling the changes made to mutually shared data items Maintenance of a large software system is tedious and costly
15
+
Features of OOPS
Polymorphism
Improvement over the structured programming paradigm Emphasis on data rather than algorithm Data abstraction is introduced in addition to procedural abstraction Data and associated operations are unified into a single unit which is termed as Object Programs are designed around the data being operated, rather than operations themselves (data decomposition-rather than algorithmic decomposition) Relationships can be created between similar, yet distinct data types Examples: Java, C++, Smalltalk, Eiffel. etc.
16
whereas,
OOPs, data is encapsulated with the associated functions (or operations), such encapsulated form or capsule is called an object
17
Hence, OOP contains FOP and so OOP can be referred to as the super set of FOP (like C++. which is a superset of C)
Unlike traditional languages, OO languages allow localization of data and code and restrict other objects from referring to its local region [see the object figure (in previous slide)] For this, OOP is centered around the concepts of objects, such as:
Encapsulations, Abstract data types, Inheritance, Polymorphism, Message based communication, etc.
During the execution of a program, the objects interact with each other by sending messages and receiving responses. For Example, in a program to perform withdrawals from an account, a customer object can send a withdrawal message to a bank account object. Means, An object communicating with other objects need not be aware of the internal working of the objects with which it interacts.
18
Thanks
19