Study sheet: Object-Oriented Programming Foundations

Course Outline

  1. Programming Paradigms and Procedural Limits
  2. Object-Oriented Programming Essentials
  3. Classes Objects and Members
  4. Encapsulation Abstraction and Hiding
  5. Inheritance and Polymorphism
  6. Binding and Message Passing
  7. Benefits of Object-Oriented Programming

1. Programming Paradigms and Procedural Limits

Key Concepts & Definitions

  • Programming language : A language used to write instructions and tell a computer how to perform specific tasks.
  • Procedural programming : An approach in which a program is written as a sequence of steps or procedures to solve a problem and executes instructions from top to bottom.

★ Must-know

  • The main limitations are:
    • difficult code reuse
    • increasingly difficult error checking
    • dependence between code sections
    • unsuitability for real-world applications
    • lack of data security
    • difficult maintenance in large programs

Further detail

  • Procedural programming is easy to learn, supports code reuse through functions, and is suitable for small and medium-sized programs.

Memory Hook

Procedural programming follows steps; OOP organizes data and behavior around objects.

2. Object-Oriented Programming Essentials

Key Concepts & Definitions

  • Object-oriented programming : A programming approach that uses classes and objects, combining data and the functions that operate on it into a single object representing a real-world entity.

★ Must-know

  • The main purposes of OOP are: code reuse through inheritance, code security through access control, binding data to its operating functions, hiding unnecessary details through abstraction and encapsulation, managing complex systems level by level, reducing duplication through reusable classes and methods

  • An object represents a real-world entity through attributes, which describe its data, and methods, which describe its behavior.

Further detail

  • The car example contains:
    • the car as the object
    • color as an attribute
    • brand as an attribute
    • model as an attribute
    • speed as an attribute
    • Start() as a method
    • Stop() as a method
    • Accelerate() as a method
    • Brake() as a method

Memory Hook

Picture a car object containing its color, speed, Start(), Stop(), and Accelerate() functions.

3. Classes Objects and Members

Key Concepts & Definitions

  • Class : A user-defined data type and blueprint for creating objects that contains data members and member functions.
  • Object : An identifiable instance of a class that represents a real-world entity and has state and behavior.
  • Data member : A variable declared inside a class, such as a student's roll number, name, or marks.
  • Method : A block of code defined inside a class that performs a specific task or action.

Essential Points

📌 A class is a logical blueprint that defines attributes and methods and does not occupy memory until objects are created, whereas an object is a physical instance that occupies memory, contains actual attribute values, and can use those methods.

Memory Hook

A class is the blueprint; an object is the created entity with actual values.

4. Encapsulation Abstraction and Hiding

Key Concepts & Definitions

  • Encapsulation : The wrapping of data and the functions that operate on it into a single unit while preventing direct access to the data.
  • Data abstraction : Provides only essential information about data to the outside world while hiding background implementation details.
  • Information hiding : Protects important or sensitive data from unauthorized access, such as an ATM's PIN, bank account details, and account balance.

Essential Points

  • An ATM exposes:
    • withdrawal
    • deposit
    • balance checking
    • PIN changing

Memory Hook

An ATM shows buttons and results while hiding PIN verification, encryption, and cash-dispensing mechanisms.

5. Inheritance and Polymorphism

Key Concepts & Definitions

  • Inheritance : The capability of a class to derive properties and characteristics from another class, promoting code reuse, reducing duplication, and simplifying maintenance.
  • Polymorphism : Means having many forms and allows a message to be displayed or behave in more than one form according to the situation.

Essential Points

  • Vehicle is a base or parent class, while Car, Bike, and Truck are child classes that inherit its properties and methods.

Memory Hook

A Vehicle parent passes common features to Car, Bike, and Truck children, while one person takes several roles.

6. Binding and Message Passing

Key Concepts & Definitions

  • Message passing : An OOP mechanism in which one object sends a request to another object to invoke one of its methods and perform an operation.
  • Binding : The process of associating a method call or function call with the actual method or code that will be executed.

★ Must-know

📌 Static binding, also called early binding, associates a method call with its implementation at compile time, while dynamic binding, also called late binding, associates it at runtime according to the actual object.

Further detail

  • Static binding is faster and less flexible, is used for static, final, and private methods and method overloading, and is achieved through function overloading and operator overloading.

  • Dynamic binding is slightly slower and more flexible, is used for method overriding, and is achieved through virtual functions and pointers.

Memory Hook

Static binding fixes the method at compile time; dynamic binding chooses it at runtime.

7. Benefits of Object-Oriented Programming

Key Concepts & Definitions

  • Code reusability : Code reusability means writing code once and using it multiple times, mainly through inheritance, such as Car and Bike reusing Vehicle's Start() and Stop() methods.
  • Data redundancy : Data redundancy is a condition in which the same piece of data is stored in two separate places, and common class definitions and inheritance can reduce repeated functionality.

★ Must-know

  • OOP security protects an object's data from unauthorized or accidental access and is mainly achieved through encapsulation and data hiding.

Further detail

  • OOP makes code maintenance easier by allowing existing code to be modified with new changes instead of requiring repeated rework.

Memory Hook

Reusable classes and protected data → less duplication, easier maintenance, and greater security.

Synthesis Tables

Procedural and Object-Oriented Programming

DimensionProcedural programmingObject-oriented programming
Program structureProcedures or functionsClasses containing data and code
Design approachTop-downBottom-up
Main emphasisProgram logicData and code organized around it
Data accessData flows freelyData is bound within classes
SecurityAlmost no access controlMultiple access-control levels
FeaturesNo polymorphism or inheritanceSupports polymorphism and inheritance

Static and Dynamic Binding

DimensionStatic bindingDynamic binding
Time of associationCompile timeRuntime
Other nameEarly bindingLate binding
Flexibility and speedFaster and less flexibleSlightly slower and more flexible
Typical useOverloading and static, final, or private methodsMethod overriding
MechanismFunction and operator overloadingVirtual functions and pointers

Test your knowledge

Test your knowledge on Object-Oriented Programming Foundations with 11 multiple-choice questions with detailed corrections.

1. What is the defining execution pattern of procedural programming?

2. What is procedural programming primarily characterized by?

Take the quiz →

Review with flashcards

Memorize the key concepts of Object-Oriented Programming Foundations with 12 interactive flashcards.

What is a programming language used for?

To write instructions and tell a computer how to perform tasks.

Programming Paradigm

Approach to solving problems with code

What is procedural programming?

An approach writing programs as sequences of steps executing top to bottom.

See flashcards →

Similar courses

Create your own study sheets

Import your course and AI generates sheets, quizzes and flashcards in 30 seconds.

Sheet generator