Skip to content

mo-hossam-stack/mastering-python-oop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Object-Oriented Programming (OOP) Concepts in Python

This folder contains a comprehensive collection of OOP concepts implemented in Python, organized for easy learning and reference.

📁 Folder Structure

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

🎯 Learning Path

Level 1: Fundamentals

  1. 00_oop_overview.py - Start here! Complete overview of OOP concepts
  2. 01_properties.py - Understanding property decorators
  3. 10_class_variables.py - Class vs instance variables
  4. 11_encapsulation.py - Data hiding and private attributes

Level 2: Relationships

  1. 03_inheritance.py - Class inheritance and code reuse
  2. 02_aggregation.py - Loose coupling (has-a relationship)
  3. 04_composition.py - Strong coupling (owns-a relationship)
  4. 07_super_keyword.py - Accessing parent class methods

Level 3: Advanced Methods

  1. 05_class_methods.py - Class-level operations
  2. 06_static_methods.py - Utility functions
  3. 08_magic_methods.py - Special Python methods
  4. 09_nested_classes.py - Class organization

Level 4: Advanced Concepts

  1. 12_polymorphism.py - Method overriding and flexibility
  2. 13_abstract_classes.py - Abstract base classes
  3. 14_interfaces.py - Interface contracts and protocols

Level 5: Design & Practice

  1. 15_design_patterns.py - Common OOP design patterns
  2. 16_practice_exercises.py - Test your knowledge

🚀 How to Use This Folder

For Beginners:

  1. Start with 00_oop_overview.py to understand the big picture
  2. Work through files 01-11 in order
  3. Run each file to see examples in action
  4. Modify the examples to experiment

For Intermediate Learners:

  1. Review files 01-11 quickly
  2. Focus on files 12-15 for advanced concepts
  3. Complete the exercises in 16_practice_exercises.py
  4. Create your own examples

For Advanced Learners:

  1. Study the design patterns in 15_design_patterns.py
  2. Implement the exercises in 16_practice_exercises.py
  3. Extend the examples with your own implementations
  4. Use as reference for real projects

🧪 Running the Examples

Each file can be run independently:

python 00_oop_overview.py
python 01_properties.py
python 02_aggregation.py
# ... and so on

📚 Key OOP Concepts Covered

Four Pillars of OOP:

  1. Encapsulation - Bundling data and methods
  2. Inheritance - Code reuse through class hierarchy
  3. Polymorphism - Same interface, different implementations
  4. Abstraction - Hiding complex details

Python-Specific Features:

  • @property decorators
  • @classmethod and @staticmethod
  • Magic methods (dunder methods)
  • Abstract base classes (ABC)
  • Protocols and structural typing
  • Mixins and multiple inheritance

Design Patterns:

  • Singleton Pattern
  • Factory Pattern
  • Observer Pattern
  • Strategy Pattern
  • Decorator Pattern

🔧 Prerequisites

  • Python 3.7+ (for type hints and some features)
  • Basic understanding of Python syntax
  • No external packages required (all examples use standard library)

💡 Tips for Learning

  1. Read the comments - Each file has detailed explanations
  2. Run the examples - See the concepts in action
  3. Modify the code - Experiment with different values
  4. Complete the exercises - Test your understanding
  5. Build your own examples - Apply concepts to real problems

🎓 Next Steps

After mastering these concepts:

  1. Apply to real projects - Use OOP in your own code
  2. Study advanced patterns - Learn more design patterns
  3. Explore frameworks - Study how popular libraries use OOP
  4. Practice with others - Code review and pair programming
  5. Read OOP books - Deepen your theoretical understanding

🤝 Contributing

Feel free to:

  • Add more examples
  • Improve existing code
  • Add new OOP concepts
  • Fix any errors you find
  • Suggest improvements

📖 Additional Resources


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!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages