This folder contains a comprehensive collection of OOP concepts implemented in Python, organized for easy learning and reference.
poop/
├── 00_oop_overview.py # Complete OOP overview and introduction
├── 01_properties.py # @property decorator and getters/setters
├── 02_aggregation.py # Aggregation (has-a relationship)
├── 03_inheritance.py # Inheritance (is-a relationship)
├── 04_composition.py # Composition (owns-a relationship)
├── 05_class_methods.py # @classmethod decorator
├── 06_static_methods.py # @staticmethod decorator
├── 07_super_keyword.py # super() function usage
├── 08_magic_methods.py # Dunder methods (__init__, __str__, etc.)
├── 09_nested_classes.py # Classes within classes
├── 10_class_variables.py # Class vs Instance variables
├── 11_encapsulation.py # Private attributes and data hiding
├── 12_polymorphism.py # Method overriding and polymorphism
├── 13_abstract_classes.py # Abstract base classes
├── 14_interfaces.py # Interfaces and protocols
├── 15_design_patterns.py # Common design patterns
├── 16_practice_exercises.py # Hands-on exercises
└── README.md # This file
- 00_oop_overview.py - Start here! Complete overview of OOP concepts
- 01_properties.py - Understanding property decorators
- 10_class_variables.py - Class vs instance variables
- 11_encapsulation.py - Data hiding and private attributes
- 03_inheritance.py - Class inheritance and code reuse
- 02_aggregation.py - Loose coupling (has-a relationship)
- 04_composition.py - Strong coupling (owns-a relationship)
- 07_super_keyword.py - Accessing parent class methods
- 05_class_methods.py - Class-level operations
- 06_static_methods.py - Utility functions
- 08_magic_methods.py - Special Python methods
- 09_nested_classes.py - Class organization
- 12_polymorphism.py - Method overriding and flexibility
- 13_abstract_classes.py - Abstract base classes
- 14_interfaces.py - Interface contracts and protocols
- 15_design_patterns.py - Common OOP design patterns
- 16_practice_exercises.py - Test your knowledge
- Start with
00_oop_overview.py
to understand the big picture - Work through files 01-11 in order
- Run each file to see examples in action
- Modify the examples to experiment
- Review files 01-11 quickly
- Focus on files 12-15 for advanced concepts
- Complete the exercises in
16_practice_exercises.py
- Create your own examples
- Study the design patterns in
15_design_patterns.py
- Implement the exercises in
16_practice_exercises.py
- Extend the examples with your own implementations
- Use as reference for real projects
Each file can be run independently:
python 00_oop_overview.py
python 01_properties.py
python 02_aggregation.py
# ... and so on
- Encapsulation - Bundling data and methods
- Inheritance - Code reuse through class hierarchy
- Polymorphism - Same interface, different implementations
- Abstraction - Hiding complex details
@property
decorators@classmethod
and@staticmethod
- Magic methods (dunder methods)
- Abstract base classes (ABC)
- Protocols and structural typing
- Mixins and multiple inheritance
- Singleton Pattern
- Factory Pattern
- Observer Pattern
- Strategy Pattern
- Decorator Pattern
- Python 3.7+ (for type hints and some features)
- Basic understanding of Python syntax
- No external packages required (all examples use standard library)
- Read the comments - Each file has detailed explanations
- Run the examples - See the concepts in action
- Modify the code - Experiment with different values
- Complete the exercises - Test your understanding
- Build your own examples - Apply concepts to real problems
After mastering these concepts:
- Apply to real projects - Use OOP in your own code
- Study advanced patterns - Learn more design patterns
- Explore frameworks - Study how popular libraries use OOP
- Practice with others - Code review and pair programming
- Read OOP books - Deepen your theoretical understanding
Feel free to:
- Add more examples
- Improve existing code
- Add new OOP concepts
- Fix any errors you find
- Suggest improvements
- Python Official Documentation
- Real Python OOP Tutorial
- Python Design Patterns
- Clean Code by Robert C. Martin
Happy Learning! 🐍✨
This folder is designed to be your comprehensive guide to Object-Oriented Programming in Python. Take your time, practice regularly, and don't hesitate to experiment with the code!