Thuta Learning
ရှာဖွေရန်
IntermediateProgrammingbeginner

OOP Introduction (Enhanced)

စိတ်လျှော့ပါ။ ဒီခန်းကို စာအုပ်လိုမဟုတ်ဘဲ စကားပြောသလိုပဲ၊ နားလည်လွယ်အောင် ရှင်းပါမယ်။

Python OOP Visual Guide
Class က blueprint၊ object က instance ဆိုတဲ့ OOP အခြေခံကို visual နဲ့မြင်သာစေပါတယ်။

🎯 Lesson 1: Object-Oriented Programming (OOP) Introduction

1. OOP ဆိုတာဘာလဲ?

မြန်မာ → OOP (Object-Oriented Programming) ဆိုတာ programming paradigm တစ်ခုဖြစ်ပြီး, code ကို objects (data + behavior) အနေနဲ့ စီမံခန့်ခွဲတဲ့ နည်းလမ်း။

English → OOP is a programming paradigm where code is organized into objects that combine data (attributes) and behavior (methods).

2. Why OOP?

  • Reusability → code ကို ပြန်သုံးနိုင်
  • Modularity → အပိုင်းလိုက် ခွဲရေးနိုင်
  • Maintainability → ပြန်ပြင်ရလွယ်
  • Real-world modeling → objects = real-world entities

3. OOP vs Procedural Programming

FeatureProceduralOOP
StructureFunctions + dataObjects (data + methods)
ReuseHarderEasier (inheritance)
Exampleadd(x, y)Calculator.add(x, y)

4. OOP Core Concepts

  1. Class → Blueprint (design)
  2. Object → Instance of a class
  3. Encapsulation → Hide internal details
  4. Inheritance → Reuse parent class features
  5. Polymorphism → Same method, different behavior
  6. Abstraction → Hide complexity, show essentials

5. အကျဉ်းချုပ်

✅ OOP = organize code into objects

✅ Class = blueprint, Object = instance

✅ Core principles = Encapsulation, Inheritance, Polymorphism, Abstraction

✅ Makes code reusable, modular, and maintainable

python
# ===== 1. Define a Class =====
class Dog:
    def __init__(self, name):
        self.name = name

    def bark(self):
        return f"{self.name} says Woof!"

# ===== 2. Create Objects =====
dog1 = Dog("Bobby")
dog2 = Dog("Lucky")

print(dog1.bark())  # Bobby says Woof!
print(dog2.bark())  # Lucky says Woof!

# ===== 3. Real-World Analogy =====
print(f"\n===== Analogy =====")
print("Class = Blueprint of a house")
print("Object = Actual house built from blueprint")
print("Methods = Functions like open_door(), turn_on_light()")
print("Attributes = Properties like color, size")

# ===== 4. Advantages =====
print(f"\n===== Advantages =====")
print("✅ Organizes complex code")
print("✅ Easier debugging & testing")
print("✅ Encourages reuse (inheritance, polymorphism)")
print("✅ Closer to real-world thinking")
You should see
Bobby says Woof! Lucky says Woof! ===== Analogy ===== Class = Blueprint of a house Object = Actual house built from blueprint Methods = Functions like open_door(), turn_on_light() Attributes = Properties like color, size ===== Advantages ===== ✅ Organizes complex code ✅ Easier debugging & testing ✅ Encourages reuse (inheritance, polymorphism) ✅ Closer to real-world thinking
OOP Introduction (Enhanced) | Thuta Learning