Course Overview
Course Title: Object-Oriented Programming
Instructor: Dr. Eng. Mahmoud Ismail
Course Overview
Introduces fundamental concepts of Object-Oriented Programming (OOP) using Python.
Begins with a survey of programming paradigms.
Presents fundamental principles of OOP.
Introduces object-oriented programming features, benefits, and advantages of OOP.
Discusses programming basics of Python language.
Teaches the creation of classes, objects, and constructors.
Covers encapsulation, inheritance, and polymorphism.
Examines Object-Oriented Relationships: Association, Aggregation, and Composition.
Overall Aims and Objectives of Course
Analyze, design, and implement a program to solve real-world problems based on object-oriented principles.
Familiarize with breaking down the problem into objects rather than procedures/functions.
Learn how OOP can help eliminate complexity of large projects.
Explain the difference between object-oriented programming and other programming paradigms.
Identify the components of Object-Oriented Programming including classes and objects.
Apply the concepts of abstraction, encapsulation, inheritance, and polymorphism to large-scale software.
Implement Object-Oriented Relationships including Association, Aggregation, and Composition.
Course Chapters
Programming Review and Fundamental Concepts of OOP
Review of Programming Basics Using Python
Control Flow Statements (IF& Loop)
Functions
Classes & Objects
Encapsulation
Inheritance
Polymorphism
Object-Oriented Relationships: Association, Aggregation, and Composition
Teaching and Learning Methods
Lectures
Seminars
Discussion Groups
Student Assessment Methods
Assignments: To assess intellectual, professional, and practical skills.
Midterm Exam: To assess knowledge and understanding.
Final Exam: To assess knowledge and understanding.
Weighting of Assessments
Exam + Section 7: 30 marks (25/5)
Exam + Section 12: 20 marks (15/5)
Lab (Quizzes & Assignments): 10 marks
Final Exam: 40 marks
Textbook
Gowrishankar, S., and A. Veena. Introduction to Python Programming. Chapman and Hall/CRC, 2018.
Chapter 1: Introduction to Object-Oriented Programming
Instructor: Dr. Mahmoud M. Ismail
Contact: dr.mahmoudmmi@yahoo.com, dr.eng.mahmoudmmi@gmail.com
Programming Review
Procedural Programming
Main Program: Data → Procedure1, Procedure2, Procedure3
The program is divided into small procedures. Each procedure is a set of commands callable at any time.
The main program passes data to individual calls, which are processed by procedures.
Characteristics of Procedural Programming
Program consists of a sequence of procedure calls.
A procedure call is used to invoke a procedure (sequence of calling statements).
Control proceeds right after the call where the sequence is processed.
Example of Procedural Programming
Components include:
A collection of variables with values (numbers, characters, strings, etc.).
A collection of statements that modify the values.
Data Structure Example:
struct account {
char name;
int accountId;
float balance;
float interestYTD;
char accountType;
};
Procedures:
Procedure 1:
Deposit()
Procedure 2:
Withdraw()
Procedure 3:
Transfer()
Disadvantages of Procedural Programming
Separation of Procedures and Data: Hard to reuse procedures, extend programs, and maintain code; changes can introduce bugs.
Modular Programming
A large program divided into modules, each with specific functionalities.
The main program coordinates calls to procedures in separate modules, with each module managing internal data.
Structure of a Modular Program
Main Module → Data → Module1, Module2, etc.
Each module can have separate data, allowing individualized state management.
Structured Programming
Divides programs into self-contained functions, separating data from functionality.
Less secure; no data hiding which impacts reusability.
How Structured Programming Looks at Problems
Functions and Data are maintained separately, minimizing complications.
Object-Oriented Programming Fundamentals
Definitions and Key Concepts
Object-Oriented Programming (OOP): A methodology based on objects instead of just functions and procedures, organizing programs as a set of interacting objects.
Informal Definition of Objects
Objects are real-world elements/entities which can be:
Physical Existence: e.g., customer, car, person.
Conceptual Existence: e.g., project, process, bank account.
Formal Definition of Objects
An object is an entity characterized by:
Identity: Uniquely defined by its name.
State/Attributes/Properties (data): Defined in the object's class.
Behavior/Operations/Methods: Represented by functions/methods in the object's class.
Identity, State, and Behavior Examples
Identity:
Objct1: car
State/Attributes: Type, color, engine power, number of passengers, manufacture date.
Behavior: Starting, stopping, turning on, and stopping the engine.
Example of an Object
Mouse Object:
State/Attributes: Model, interface
Behavior/Methods: Left click, scrolling, right click.
Object Characteristics
Unique Identity
Each object has a unique identity even with identical state attributes.
State Example
For Professor Mona:
Name: Mona
Employee ID: 567138
Date Hired: July 25, 2020
Status: Tenured
Discipline: Finance
Maximum Course Load: 3 classes
Behavior Example
Actions for Professor Mona:
Submit Final Grades
Accept Course Offering
Take Sabbatical
Set Maximum Course Load
Graphical Model of an Object
Attributes (variables) form the nucleus of the object.
Methods encapsulate the state variables from the rest of the program.
Example of a Student Object
Attributes:
Name, Roll Number, Semester
Methods:
Enroll(), Performance(), DisplayInfo()
Example of an Account Object
Attributes:
Balance, Account Number
Methods:
Withdraw(), Deposit(), SetAccountNumber()
Classification of Objects into Classes
Objects can be grouped into classes based on shared characteristics.
Classes define a template for creating objects with similar properties and behaviors.
Definition of Class
A class serves as a blueprint to create a group of similar objects.
Defined properties include data and operations specific to the class.
Instantiation: The process of creating an object as a member of a class.
Example of Class Definition
Class: Fruit
Objects: Strawberry, Pineapple, Banana, Apple.
Properties of Classes
All instances of a given class share the same attributes but have distinct values.
Class Vehicle Example
Class Vehicle can derive objects:
Attributes: Type, color, engine power, number of passengers, manufacture date.
Methods: Starting, stopping, turning, etc.
Example of Class Professor
Class Professor Attributes:
Name, Employee ID, Hire Date, Status, Discipline, Max Load
Class Methods:
Submit Final Grade(), Accept Course Offering(), Set Max Load(), Take Sabbatical()
Inheritance in OOP
Inheritance allows new classes to inherit properties and behaviors from existing classes (base/parent class).
Easily enables code reuse and extension of functionalities in derived (child) classes.
Polymorphism in OOP
Means "many forms." Allows a single action to be performed in different ways.
The same method can be defined across multiple classes, allowing for different implementations.
Example of polymorphism in real life: Adapting behavior based on context (e.g., a person acting differently in various environments).
Implementation of Polymorphism
Achieved through method overloading and overriding using inheritance where methods in parent and child classes have the same name.
Features of OOP
Break down programs into objects with responsibilities rather than functional steps.
Focus on object hierarchies and interactions rather than control flow.
Emphasize data over procedures.
Facilitate communication between objects through methods/functions.
Allow easy addition of new data/functions.
Benefits of OOP
Better abstractions combining information and behavior.
Improved maintainability: maintenance costs can exceed development costs.
Enhanced reusability of classes as encapsulated components.
Increased security via data hiding features.
Programs modeled on real-world structures leading to better organization.
Quick development and simplified testing.
Adaptable to changes with minimal impact on overall system design.
Final Notes
Object-Oriented Programming (OOP) converges data and methods into a singular entity—an object, further enabling structured, maintainable programming paradigms.
This comprehensive study guide systematically lays out all concepts, theories, principles, and applications discussed within the transcript, ensuring a thorough understanding of Object-Oriented Programming as taught by Dr. Eng. Mahmoud Ismail.