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

OOP Intro

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

Object-Oriented Programming (OOP) သည် program ကို real-world objects တွေလိုပုံဖော်တည်ဆောက်တဲ့ approach ပါ။ Object တစ်ခုမှာ data (attributes/fields) နဲ့ behavior (methods) ရှိပါတယ်။ ဥပမာ Student object မှာ name, age, grade ဆိုတဲ့ data ရှိနိုင်ပြီး study(), submitAssignment() ဆိုတဲ့ behavior ရှိနိုင်ပါတယ်။

Java သည် OOP ကိုအဓိကထားတဲ့ language ဖြစ်ပြီး core pillars 4 ခုရှိပါတယ်။

Encapsulation — data ကိုထိန်းချုပ်ပြီး safe access ပေးခြင်း

Inheritance — parent class မှ feature များကို child class ကယူသုံးခြင်း

Polymorphism — method တစ်ခုကို object များအလိုက် မတူညီအလုပ်လုပ်စေခြင်း

Abstraction — မလိုအပ်တဲ့ detail ကိုဖုံးပြီး important behavior ကိုသာပြခြင်း

java
class Student {
  String name;

  void study() {
    System.out.println(name + " is studying Java.");
  }
}

public class Main {
  public static void main(String[] args) {
    Student student = new Student();
    student.name = "Aung";
    student.study();
  }
}

Student class သည် blueprint ဖြစ်ပါတယ်။ new Student() က Student object တစ်ခုတည်ဆောက်ပါတယ်။ Object ထဲက name field ကို set လုပ်ပြီး study method ကိုခေါ်ထားပါတယ်။

You should see
Aung is studying Java.

လက်တွေ့အသုံးချမှု

User, Product, Order, Payment, Course, Lesson စတဲ့ app entities တွေကို class/object နဲ့တည်ဆောက်ပါတယ်။

ဒီနေရာမှာ လူအများမှားတတ်တယ်

  • Class ကို object လို့ထင်တာ၊ object မဆောက်ဘဲ instance field/method ကိုခေါ်တာတွေ beginner တွေမှာတွေ့ရပါတယ်။
OOP Intro | Thuta Learning