Solid Principle : Every developer should know
What is solid principle? Why we should take care about it?
မိတ်ဆက်
ကိုယ်ရဲ့ coding skill ပိုပီးကောင်းမွန်အောင် clean code ကို အခြေခံပီး ဘယ်လို ရေးရမလဲ ။ good practices ဆိုတာတွေကို developer တိုင်း နားလည်ထားသင့်တယ်။ Technical ပိုင်းဖြစ်တဲ့ (languages and frameworks) မကဘဲ သိသင့်သိထိုက်တဲ့ theory တွေဖြစ်တဲ့ algorithms, data structure, design patterns, principles လည်း နားလည်ထားသင့်တယ်။ဒီ article series မှာတော့ OOP ရဲ့ အခြေခံကျတဲ့ solid principle ကို ဆွေးနွေးသွားမယ်။
well-written code ကို လေ့လာရင်း သဘောကျတဲ့ tips တွေကို ဒီ post မှာရှင်းပြမှာ ဖြစ်တဲ့အတွက် သင့်ရဲ့
coding skill လည်း တိုးတက်လာလိမ့်မယ်လို့ မျော်လင့်ပါတယ်။ ဒီ article က SOLD principle series အစဖြစ်လို့ သူ့ရဲ့ over view ကို ဖော်ပြသွားပါမယ်။
So, Why you should know about it?
project တစ်ခုကို ပီးအောင် ရေးလိုက်ပီး ဆိုပါဆို့။နောက်ဒီ project မှာဘဲ feature အသစ်တွေ ထပ်ထည့်ချင်တယ်။ ရှိပီးသား code ပါ ပြန် change ရမယ်။ တစ်ခါတစ်လေ ရှိပီးသား program ကို effect သွားဖြစ်တယ်။ effect ဖြစ်တဲ့ code တွေပါ refactoring ပြန်လုပ်ရတယ်။ project time လည်းသွားထိတယ်။ ဒါတွေက principle တွေကို မလိုက်နာဘဲ ရေးထားတဲ့ bad code ရဲ့ အကျိုးဆက်တွေလို့ ပြောရပါလိမ့်မယ်။
Good code = Changeable
Bad code = Concrete (:
သင် project ရဲ့ code တွေက bad code ဖြစ်နေရင် ဘာမှမဖြစ်ပါဘူး(it’s just normal). တစ်ခါတစ်လေ project က deadline ရောက်နေတာတို့၊ client ရဲ့ pressure ကြောင့်တို့စတဲ့ The Broken window Theory ကို ဖြစ်စေတဲ့ အချက်တွေကြောင့် ဆရာ့ဆရာ programmer တွေတောင် ဖြစ်တတ်ပါတယ်။ ဒီနေရာမှာ ဘာကို သိထားသိလဲဆိုတော့ code တွေက bad code နဲ့ project ပီးသွားတယ်။ ဒါက program ကို breaking လုပ်လိုက်တာ ပီးစလွယ်လုပ်လိုက်တာပါဘဲ။ program ကို solution ထုတ်ပီးရေးထားတာ၊ deadline အမီပီးသွားတာလို့ မခေါ်သင့်ပါဘူး။ project code ကို refactoring မလုပ်ဘဲနဲ့ပီးသွားရင် နောက်လာမဲ့ new feature တွေကို ပီးမြောက်ဖို့ဆိုတာ ပိုပီး ခက်ခဲလာပါလိမ့်မယ်။
Why ဆိုတာကို သဘောပေါက်ပီးထင်တယ်။ ဘာကြောင့် သိသင့်လဲ နားလည်သွားရင် what and how ကို ဆက်သွားပါမယ်။ အဆုံးသတ် memeကတော့ :)
So, What is it?
SOLID ဆိုတာဘာလဲ။ Five Object Oriented Design(OOD) principle ရဲ့ အတိုကောက်လို့ မှတ်နိုင်တယ်။ Robert C.Martin (Uncle Bob)က ရေးသားပြုစုခဲ့တာပါ။ Developer တိုင်းသိထားသင့်တဲ့ principle တစ်ခု ဘာလို့ဆို ဒီကောင်က coding နဲ့ maintainable လုပ်တဲ့ အချိန်မှာ အတော်လေးကောင်းပါတယ်။ ဒါပြင့် open source code က သူများ ဘာရေးထားလဲဆိုတာပါ ဖတ်နိုင်လာမယ် ။
ဒီ principle ကနေ programmer တွေ cleaner code ဖြစ်အောင်၊ separating responsibilities, decreasing couplings, facilitating refactoring and code တွေ reusable ဖြစ်အောင် function တွေ data structure တွေကို class တစ်ခုအနေနဲ့ ဘယ်လိုစီမံရလဲ ဆိုတာကို သိနိုင်ပါတယ်။
Get Yan Yan Chan’s stories in your inbox
Join Medium for free to get updates from this writer.
SOLID ကနေပေးတဲ့ အရေးကြီးတာတွေက
- Make the code more understandable, clear and concise — code ကို သူများနားလည်လွယ်အောင်၊ တိကျမှုရှိအောင် လုပ်ရပါမယ်။
- Make the code more flexible and tolerant to changes — code ကို ပြောင်းလွယ်၊ပြင်လွယ်အောင် လုပ်ရပါမယ်။
- Increase the code adherence to OO principles — code က OO principles ကို လိုက်နာရမယ်။
ဒီ article series ကို ဖတ်ပီးသွားရင် principle တစ်ခုစီရဲ့ theory ကိုနားလည်ပီး ကိုယ့်ရဲ့ coding skill ကို improve ဖြစ်လာမယ်လို့ မျှော်လင့်ပါတယ်။ Better programmer ဖြစ်ချင်ရင်တော့ practices များများလုပ်ဖို့လိုပါတယ်။ အသေးစိတ် implementation ကိုတော့ articles တစ်ခုချင်းဆီမှာ ဖော်ပြထားပါတယ်။
Open Closed Principle: Make your code cost-free and flexible | by Yan Yan | Jul, 2022 | Medium
Liskov Substitution Principle: Improves the quality of your code | by Yan Yan | Jul, 2022 | Medium
Interface Segregation Principle: The way to be a developer | by Yan Yan | Aug, 2022 | Medium
Dependency Inversion Principle: How you should write code | by Yan Yan | Jul, 2022 | Medium
Your Contribution
- clap button ကို နှိပ်ပီး သိချင်တာရှိရင် comment section မှာ ချန်ထားခဲ့ပါ
- ဒီ article ကို နှစ်သက်ရင် shar ပီး contribute လုပ်ပေးပါ









