Lecture 14
Introduction to Object-Oriented Programming (OOP)
1. OOP Overview
o Object-Oriented Programming (OOP): A programming paradigm
that organizes code around objects, which represent real-world
entities or concepts.
o Objects: Instances created based on the blueprint provided by
classes.
o Classes: Define the attributes (data) and methods (functions) that
objects will have.
Recap: Principles of OOP
1. Four Pillars of OOP:
o Abstraction: Modeling real-world objects in a specific context,
representing only the relevant details with high accuracy while
omitting the irrelevant ones.
o Encapsulation: Hiding parts of an object's state and behavior from
other objects, exposing only a limited interface to the rest of the
program.
o Inheritance: Building new classes on top of existing ones, enabling
code reuse.
o Polymorphism: The ability of a program to detect the real class of
an object and call its implementation, even when its real type is
unknown in the current context.
What is a Design Pattern?
1. Definition:
o Design Patterns: Typical solutions to commonly occurring
problems in software design. They provide a high-level description
of a solution to a problem, rather than a step-by-step algorithm.
o Difference from Algorithms: While algorithms define a clear set
of actions to achieve a specific goal, patterns offer a more abstract
solution to a problem.