Iterator Pattern

Iterator Pattern က behaviour pattern တစ်ခုပါ။​ Composite Pattern လိုမျိုး code တွေမှာ ဆိုရင် အဆုံးကို မသိနိုင်ပါဘူး။ Directory အောက်မှာ Directory တွေက တောက်လျှောက် ရှိနိုင်တယ်။ Tree ကို traversal သွားရင် BFS နဲ့ DFS algorithm နှစ်ခု ရှိပါတယ်။ နှစ်သက်ရာနဲ့ သွားလို့ ရအောင်လည်း လုပ်ချင်တယ် ဆိုရင် Iterator pattern က ပို အဆင်ပြေပါတယ်။ Iterator Pattern က loop လုပ်ရသည့် အခါတွေ မှာ သုံးလို့ရပါတယ်။ Class Diagram ကို ကြည့်ရအောင်။ ကျွန်တော်တို့ Directory နဲ့…More

Composite Pattern

Composite Pattern ကတော့ structural design pattern ဖြစ်ပါတယ်။ Composite က Tree Structure တွေ မှာ အသုံးများပါတယ်။ Tree Structure ပြဿနာတွေ ဆိုရင် Composite လို့ ဆိုလို့ရတယ်။ ဥပမာ File Structure တစ်ခုကို ကြည့်ရအောင်။ Folder တစ်ခု အောက်မှာ Folder လည်း ရှိတယ်။ File လည်း ရှိနိုင်ပါတယ်။ Linux က file system တွေမှာ ဆိုရင် root(/) အောက်မှာ အခါ folder နဲ့ file တွေ ရှိပြီး အဆင့်ဆင့် ခွဲ သွားတာ မျိုးပေါ့။ / /var/…More

State Pattern

State Pattern ကတော့ Behaviour Pattern တစ်ခုပါ။ State Pattern ကတော့ strategy pattern နဲ့ တူသလို နဲ့ မှားတတ်ပါတယ်။ State Pattern ကတော့ strategy pattern လိုပါပဲ။ ဒါပေမယ့် သူက state တစ်ခု ကနေ တစ်ခု ပြောင်းလဲ သွားတာ ရှိပါတယ်။ ဥပမာ။ Level 1 မှာ play 1 point ရမယ်။ Level 1 မှာ point 100 ရရင် Level 2 ကို ပြောင်းမယ်။ Level 2 မှာ play တစ်ခါ လုပ်တိုင်း 2…More

Template Method Pattern

Template ဆိုတာကတော့ ကျွန်တော်တို့တွေ ကြားနေကြပါ။ ပုံမှန် အားဖြင့် အရန်သင့်ရှိပြီးသားထဲကမှ လိုအပ်သည့် အပိုင်းလေးကိုပဲ ပြင်ပြီး သုံးတာပါ။ Template Method Pattern ကလည်း အဲလိုခပ်ဆင်ဆင်ပါပဲ။ Template Method Pattern က Behavioral Patterns တစ်ခုပါ။ Class Diagram ကို ကြည့်ရအောင်။ Java code က abstract class FileOpener { private String filePath; public FileOpener(String filePath) { this.filePath = filePath; } // Template method that defines the steps for opening the…More

Strategy Pattern

Strategy pattern က behavioral design pattern တစ်ခုပါ။ Strategy Pattern အကြောင်းပြောရရင် ပြဿနာ တစ်ခု ကို ဖြေရှင်းဖို့ အတွက် နည်းလမ်း မျိုးစုံ ရှိပါတယ်။ အဲဒီ နည်းလမ်းထဲက ဘယ် နည်းလမ်း နဲ့ ရှင်းမလဲ ဆိုတာကို ပြောပြပေးလိုက်တာပါပဲ။ ဥပမာ Google Map မှာ Point A ကနေ Point B ကို သွားမယ်။ အဲဒီ အခါမှာ သွားဖို့ Strategy တွေက ကား နဲ့ သွားမယ် လမ်းလျှောက် သွားမယ် bus နဲ့ သွားမယ် ဆိုပြီး strategy ရှိလာပါတယ်။ Strategy ပေါ်မှာ…More

Command Pattern

Command pattern က behavioral design pattern တစ်ခုပါ။ Text-Editor app တစ်ခု ဖန်တီးသည့် အခါမှာ toolbar မှာ buttons တွေ အများကြီး ရှိပါ မယ်။ Copy, Paste, Undo, Redo စသည့် button တွေ အများကြီး ရှိပါတယ်။ Save လုပ်ဖို့ အတွက် Button ကနေ ရှိနိုင်တယ်။ Menu ကနေ ရှိနိုင်တယ်။ Shortcut ကနေလည်း ရှိနိုင်ပါတယ်။ Button တစ်ခု ဆီကနေ function ခေါ်မယ့် စား SaveCommand ဆိုပြီး command pattern နဲ့ ရေးတာ ပိုအဆင်ပြေပါမယ်။ ပုံမှာ ဆိုရင်…More

Facade pattern

Facade Pattern က Structural-Pattern တစ်ခု ဖြစ်ပါတယ်။ သူက တံခါးပေါက်နဲ့ တူပါတယ်။​ System အကြီးရဲ့ အောက်မှာ sub system တွေ ရှိနေပြီး သူတို့ကို Service Class ကနေ တဆင့်ခိုင်းစေတာပါ။ Laravel က Facade နဲ့ Facade Pattern က မတူပါဘူး။ ဥပမာ နားလည်အောင် အောက်က Diagram ကို ကြည့်ကြည့်ပါ။ HomeTheaterFacade က main system ဖြစ်ပြီး သူ့ဆီမှာ sub system တွေ ဖြစ်သည့် DVD Player, Projector, Sound System တွေ ရှိနေပါတယ်။ ကျွန်တော်တို့ ဘယ် DVD…More

ကျွန်တော် ဘာလို့ Monolithic ပဲ ရွေးချယ်တာလဲ

Microservice နဲ့ ပတ်သက်ပြီး developer တွေ မေးနေကြတာရှိတယ်။ Microservice ဆိုတာ ဘာလဲ။ သိဖို့ လိုလား။ ပြောင်းသင့်လား။ သုံးသင့်လား ဆိုပြီး။ ဘယ်အရာ မဆို pros and consရှိတာပဲ။ အခု အချိန် ထိ Microservice နဲ့ Monolithic ဆိုရင် Monolithic နဲ့ ပဲ အမြဲစ ဖို့ပဲ အကြံပေးတယ်။ Monolithic ကိုပဲ ရွေးချယ်ဖို့ ဆုံးဖြတ်တယ်။ Monolithic က ခေတ်မရှိတော့ဘူး။ Netflix တို့ Facebook တို့ Microservices တွေ နဲ့ ရေးနေကြတာ ကျွန်တော်တို့ လည်း ရေးသင့်တယ်။ သိထားသင့်တယ် လို့ ထင်ကောင်းထင်ကြတယ်။ သိထားတာကတော့ သိထားသင့်တယ်။…More