Comprehensive Study Notes on Object-Oriented Programming Principles
C++ and Structure-Oriented Programming
Nature of C++: C++ is described as both a structured program and a language that supports object-oriented programming.
Structure-Oriented Programming Definitions:
It is an approach where functions are the basic entities.
Programs involve the use of functions for coding.
Complex problems are divided into numerous sub-tasks or sub-problems to find a solution.
The main problem is broken down into functions which interact with each other to solve the complication.
Examples of Procedural Elements:
Standard functions like
printfandscanfin C.User-defined functions, such as those used to divide or calculate area.
Introduction to Object-Oriented Programming (OOP)
Basic Entity: In OOP, the basic entity is the "Object," whereas in structure-oriented programming, the basic entity is the "Function."
Handling Complexity: OOP is designed to handle complex problems by separating them into different parts.
Object Definition:
An object is a real-world entity or a "real-time entity."
It can be a living or non-living thing.
An object is an "instance of a class."
It is used to store the memory of the user.
Examples of Objects:
Visible things: Mobile phones, laptops, books, tables, chairs, computers.
Abstract entities: Teaching faculty or specific roles in a college application.
Properties and Attributes:
Every object has specific properties or attributes that describe it.
Example: A car has a property like "color."
Example: A laptop has specific specifications that describe it.
Example: In a college application, tables, shares, and computers are objects with their own attributes.
Classes: The Blueprints of Objects
Definition of Class:
A class is a blueprint of the object.
A class is defined as a collection of objects.
Relationship between Class and Objects:
number of objects can be derived from a single class.
While the blueprint (class) remains the same, the attributes of different objects derived from it can change.
Example: A single blueprint for a whole house can be used to represent the class, while individual houses or rooms are objects.
Encapsulation and Data Hiding
Definition of Encapsulation:
It is the wrapping up of data and its associated methods into a single unit.
Analogies used: A "capsule" or "tube tablet" where the contents are enclosed.
Components of Encapsulation:
Variables and classes work together.
It involves data and the corresponding methods (processes).
Example: Mobile Number and Balance:
A mobile phone has attributes like a mobile number and email ID.
The "mailing" or "calling" process involves these data points.
Encapsulation ensures that access permissions are set for attributes like mobile numbers and bank balances.
Data Hiding:
Encapsulation allows for data hiding.
It prevents unauthorized access to sensitive data (e.g., bank balance or exact call data records).
Data Abstraction
Definition: Providing only the needed information to the user while hiding the background details or implementation.
Distinction from Hiding: While data hiding protects the data, abstraction focuses on providing the "abstract data" or necessary interfaces.
Examples:
A user can perform a bank withdraw operation without needing to see the underlying complex data structures.
Users see the email function but not the internal data handling of the email ID.
Polymorphism
Definition: The word means "many forms."
Concept: A single character or entity playing different roles depending on the situation.
Example: A person has multiple phases or roles based on the context (situation). The behavior changes according to the environment even though the entity remains the same.
Inheritance
Definition: The process of deriving the properties of another object.
Mechanism: A new object can acquire the features of an existing object.
Example: A software update in a mobile phone. The existing features are inherited and expanded upon in the updated version.
Binding and Message Passing
Static vs. Dynamic Binding:
Binding refers to the link between a function call and the actual code executed.
Dynamic Binding: This occurs when the code to be executed in response to a function call is decided at runtime rather than compile time. It is associated with objects in motion or specific "moments."
Message Passing:
Definition: It is the communication process between two objects.
In OOP, objects interact with each other by sending and receiving information, which is termed "message passing."
System Transcript Metadata
Chapter 2 Log Entry: The transcript contains a system error log during the transition between chapters:
Code:
AccessDeniedMessage:
Access DeniedRequestId:
NNNEJZJB7WFT6GCAHostId:
YBxVcBbOaFW3x9ebYU9Z3H4pfntHXn2DZyamcBeUI8Opxa5ipgd62dro8ABYm4PRm897suVXc3GsLtGazQoibyr/uvz3qTTb
Questions & Discussion
Question: What is meant by structure-oriented programming?
Response: It refers to programming where functions are the primary focus. One must explain it in sequence. Complex problems are divided into sub-tasks (functions like
printfandscanf).
Question: Is an object a living or non-living thing?
Response: It can be both. Examples include a mobile or laptop (non-living) or a person/faculty (living). It is a real-world entity with a shape, purpose, and attributes.
Question: Can you elaborate on the relationship between a class and multiple objects?
Response: number of objects can be derived from a single class. The class acts as the collection or the blueprint for those objects.
Question: Are there any doubts regarding the concepts of Polymorphism, Inheritance, or Binding?
Response: The participants indicated they had no further doubts at that time.