0% found this document useful (0 votes)
1 views2 pages

OOP Notes

Object-Oriented Programming (OOP) is a programming paradigm that utilizes 'objects' to bundle data and behavior, promoting modularity and reusability. Key concepts include classes, objects, encapsulation, inheritance, and polymorphism, which enhance maintainability and abstraction. However, common pitfalls include overengineering and tight coupling between classes.

Uploaded by

Scott Richards
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views2 pages

OOP Notes

Object-Oriented Programming (OOP) is a programming paradigm that utilizes 'objects' to bundle data and behavior, promoting modularity and reusability. Key concepts include classes, objects, encapsulation, inheritance, and polymorphism, which enhance maintainability and abstraction. However, common pitfalls include overengineering and tight coupling between classes.

Uploaded by

Scott Richards
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Object-Oriented Programming

Class Notes: Object-Oriented Programming (OOP)

---

# Object-Oriented Programming (OOP)

## What is OOP?

- A programming paradigm based on "objects": bundles of data and behavior.

- Makes code modular, reusable, and easier to maintain.

## Key Concepts

- **Class:** Blueprint for creating objects. Defines attributes (data) and methods (behavior).

- **Object:** An instance of a class.

- **Encapsulation:** Hides internal state, exposing only what is necessary.

- **Inheritance:** Allows new classes to reuse, extend, or modify existing code.

- **Polymorphism:** Different classes can define the same method in their own way.

## Example

class Animal:

def speak(self):

return "Some sound"

class Dog(Animal):

def speak(self):
return "Woof!"

animals = [Animal(), Dog()]

for a in animals:

print(a.speak())

- Shows **polymorphism**: same `speak` call works on different types.

## Benefits

- Reuse: Inheritance allows building on existing code.

- Maintainability: Changes in one class can ripple safely.

- Abstraction: Hide complexity behind interfaces.

## Common Pitfalls

- Overengineering: Don't force everything into classes.

- Tight coupling: Classes depending too heavily on each other.

You might also like