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

Debug၊ Review နဲ့ Git Workflow ပေါင်းစပ် စိန်ခေါ်မှု

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

ဒီခန်းပြီးရင် ဘာတတ်သွားမလဲ

  • Debug၊ Review နဲ့ Git Workflow ပေါင်းစပ် စိန်ခေါ်မှု ကို ကိုယ်တိုင် လေ့ကျင့်ကြည့်မယ်
  • သင်ခဲ့ပြီးသား skill တွေကို practice လုပ်ပြီး ခိုင်မာအောင်လုပ်မယ်
  • အမှားရှာ၊ ပြင်တတ်၊ ကိုယ်တိုင် check လုပ်တတ်မယ်

ခဏလေး ဒီလိုပဲ စဉ်းစားကြည့်

ဒီ lesson က ခန်းအသီးသီးက သင်ခဲ့တဲ့ debugging, code review, secrets/security, tests, git commit skill တွေကို တစ်ခါတည်း ပေါင်းစပ်ပြီး အသုံးချကြည့်တာပါ။ Beginner exercise ထက် ခက်ပါတယ် — problem တစ်ခုတည်းမက workflow တစ်ခုလုံးကို sequence အတိုင်း ဖြေရှင်းရမှာမို့ပါ။ AI ကို အကူအညီယူပေမယ့် ဆုံးဖြတ်ချက်တိုင်းကို review, understand, verify လုပ်ဖို့ တောင်းဆိုထားပါတယ်။ Task တွေကို အစဉ်လိုက် လုပ်ဆောင်ဖို့ အကြံပြုပါတယ်။

လေ့ကျင့်ခန်းများ

Task 1: အောက်က broken function ကို AI ကို ပေးပြီး "ဘာကြောင့် crash ဖြစ်တာလဲ ရှင်းပြပြီး fix ပေး" လို့ prompt လုပ်ကြည့်ပါ၊ diff ကို line-by-line review လုပ်ပါ။ Task 2: code sample ထဲက hardcoded API key ကို ရှာထုတ်ပြီး .env ကို ရွှေ့ကာ .gitignore ထဲ ထည့်ပါ။ Task 3: fix ထားတဲ့ function အတွက် edge case (empty array) ကို စစ်တဲ့ test case တစ်ခု ရေးပါ။ Task 4: အဲဒီ change အားလုံးကို logical unit လေးခု ခွဲပြီး conventional-commit style message တွေနဲ့ commit လုပ်ကြည့်ပါ (git push အထိ မဆွဲလိုက်ပါနဲ့၊ local commit ပဲ လုပ်ကြည့်ပါ)။

Code နမူနာ

javascript
// Task 1: buggy function — crash ဖြစ်ရတဲ့ အကြောင်းရင်းကို ရှာပါ
function averagePrice(items) {
  const total = items.reduce((sum, item) => sum + item.price, 0);
  return total / items.length; // items ဗလာဆိုရင် NaN ပြန်လာမယ်
}

// Task 2: hardcoded secret ကို ရှာပြီး .env ထဲ ရွှေ့ပါ
const STRIPE_KEY = "sk_live_51Hxxxxxxxxxxxxxxxxxxxxxxxx";

function chargeCustomer(amount) {
  return fetch("https://api.stripe.com/v1/charges", {
    headers: { Authorization: `Bearer ${STRIPE_KEY}` },
    method: "POST",
    body: JSON.stringify({ amount }),
  });
}

// Task 3: ဒီ edge case အတွက် test တစ်ခု ရေးပါ
// test("empty array should not crash", () => { ... })
You should see
Bug fix, secret ဖယ်ရှားမှု, test တစ်ခု, နဲ့ commit လေးခုကို local repo history မှာ တွေ့ရမည်ဖြစ်ပြီး secret string ဟာ code ထဲမှာ မကျန်တော့ပါ။

၅ မိနစ် စမ်းကြည့်

5 မိနစ် timer တင်ပြီး Task 1 နဲ့ 2 ကိုပဲ ဦးစားပေး ဖြေရှင်းကြည့်ပါ — bug fix diff ကို review လုပ်ပြီး secret ကို .env ထဲ ရွှေ့နိုင်ရင် အောင်မြင်ပါပြီ။

သတိလေးတစ်ချက်

Real API key နဲ့ practice မလုပ်ပါနဲ့ — sample key ပုံစံ dummy string ကိုပဲ သုံးပြီး secret-removal flow ကို practice လုပ်ပါ။

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

  • Empty array/null case ကို AI fix ထဲမှာ handle မလုပ်ပေးတာကို မသတိမထားဘဲ accept လုပ်လိုက်တတ်တယ်
  • Secret ကို .env ထဲ ရွှေ့ပေမယ့် .gitignore ထဲ မထည့်လိုက်လို့ history ထဲ ဝင်သွားတတ်တယ်

အခု ကိုယ်တိုင် စမ်းကြည့်

5 မိနစ် timer တင်ပြီး Task 1 နဲ့ 2 ကိုပဲ ဦးစားပေး ဖြေရှင်းကြည့်ပါ — bug fix diff ကို review လုပ်ပြီး secret ကို .env ထဲ ရွှေ့နိုင်ရင် အောင်မြင်ပါပြီ။

You'll know it worked when: Bug fix, secret ဖယ်ရှားမှု, test တစ်ခု, နဲ့ commit လေးခုကို local repo history မှာ တွေ့ရမည်ဖြစ်ပြီး secret string ဟာ code ထဲမှာ မကျန်တော့ပါ။