Saturday, August 13, 2011

Quantum Computing မိတ်ဆက်

He begins working calculus problems in his head as soon as he awakens. He did calculus while driving in his car, while sitting in the living room, and while lying in bed at night.
—Mary Louise Bell divorce complaint

သူဟာ အိပ်ရာက နိုးတာနဲ့ ကဲကုလပ်စ်ပြဿနာတွေကို စ စဉ်းစားပြီ။ ကားမောင်းနေရင်းနဲ့လည်း ကဲကုလပ်စ်။ ဧည့်ခန်းထဲထိုင်နေတဲ့ အချိန်လည်း ကဲကုလပ်စ်။ နောက်ဆုံး ညအိပ်ရာဝင်တဲ့ အချိန်တောင် ဒီ ကဲကုလပ်စ် အကြောင်းပဲ စဉ်းစားနေတာ..။

[ရူပဗေဒပညာရှင် ရစ်ချတ်ဖိုင်းမန်း ၏ ဒုတိယဇနီး မေရီလူစီဘဲလ် က လင်မယား ကွာရှင်းခွင့်အတွက် တရားရုံးတွင်လျောက်ထားသော စကား။]

***********************************************
Quantum Computing မိတ်ဆက်

နိုဘယ်ဆုရ ကမ္ဘာကျော် အမေရိကန် ရူပဗေဒပညာရှင် ရစ်ချတ်ဖိုင်းမန်း Richard Phillips Feynman (May 11, 1918 – February 15, 1988) က၊ quantum mechanics ရဲ့အကျိုးသက်ရောက်မှုတွေကို ထိထိရောက်ရောက် အသုံးပြုနိုင်မယ့် computer တစ်မျိုး ၊ တနည်းပြောရရင်တော့ quantum computer အကြောင်းကို ၁၉၈၂ ခုနှစ်လောက်မှာ စတင်ပြီး စိတ်ကူးကြံစည်ခဲ့ပါတယ်။

ကနေ့အခါမှာ ကွန်ပျူတာ ပရောဆက်ဆာတွေ ထုတ်လုပ်ရာမှာ VLSI (Very-large-scale integration) နည်းပညာကို အသုံးပြုထားတဲ့ အတွက်ကြောင့် ကွန်ပူျတာတွေရဲ့ လုပ်ဆောင်နိုင်မှု အမြန်နှုန်းစွမ်းရည် (performance) ဟာ တနေ့တခြားတိုးတက်လာနေတယ်ဆိုတာ မိတ်ဆွေတို့ သတိထားမိမှာပါ။ မိတ်ဆွေ တို့ သိတဲ့အတိုင်းပဲ [ဟေ့..ဟေ့..ဒို့ ဘာမှမသိဘူးနော်..:-)] VLSI ဆိုတာ ကွန်ပူျတာ processor ရဲ့ circuit မှာ transistors ပေါင်း၊ ထောင် သောင်း သိန်း သန်း ချီပြီး ထည့်သွင်းတည်ဆောက် တဲ့ နည်းပညာကိုးဗျ။

ဒါကြောင့်..

-Computer Processor ကို များများ Powerful ဖြစ်အောင် transistors များများထည့်ရမယ်။

-(Processor အရွယ်အစားကို ကိန်းသေထားမယ်ဆိုရင်တောင်)

Processor တခုမှာ transistors များများထည့်နိုင်ဖို့ transistors ရဲ့ အရွယ်အစားကို သေးငယ်သည်ထက် သေးငယ်အောင် လုပ်ရမှာပေါ့။

-နောက်တဆင့်အနေနဲ့ Processor အရွယ်အစားကိုပါ  ပိုမို သေးငယ်လာစေချင်ရင်...

transistors  အရွယ်အစားဟာ သေးသည်ထက်သေး သေးသည်ထက်သေး သေးလာရမှာပေါ့။

အေးဗျာ…အဲဒီမှာ စတွေ့တာပဲ [ဓါတ်တိုင်နဲ့ မခိုင် နဲ့ ;-)]။

-transistors ရဲ့ အရွယ်အစားကို ဘယ်လောက်အကန့်အသတ်ထိ သေးငယ်နိုင်မလဲ။ တနည်းပြောရရင် အသေးဆုံး ထားနိုင်မယ့်အရွယ်အစား။ အဲဒီထက် ထပ် သေးငယ်လို့မရတော့တဲ့ အနေအထား ဆိုတဲ့ Calculus ရဲ့ limit, minimum, maximum ဆိုတဲ့ သဘောတရားတွေ..။

-အရာဝတ္ထုတွေဟာ သေးလွန်းမက သေးငယ်လာတဲ့အခါ သူ့ရဲ့ လားရာ အပြုအမူ အကျိုးသက်ရောက်မှုတွေဟာ ခန့်မှန်းတွက်ချက်ဖို့ခက်လာပြီး မသေချာ မရေရာဖြစ်လာတယ် ဆို တဲ့ quantum mechanics ရဲ့ သီအိုရီတွေ နဲ့

-လက်ရှိ ရှိပြီးသား Computer Science theory တွေ ပေါင်းစပ် ရတော့မယ့် အခြေအနေကို ဆိုက်ရောက်လာပြီကိုး ဗျ။

ကျွန်တော်တို့ဟာ ရူပဗေဒတို့ သင်္ချာတို့ ကို အတိုင်းအတာတရပ်အထိ ခြေခြေမြစ်မြစ် လေ့လာသိရှိထားမယ်ဆိုရင် အခု ဆွေးနွေးမယ့် Quantum Computing အကြောင်းဟာ တော်တော်လေး ရသမြောက်မယ့် အားတက်စရာ စိတ်လှုပ်ရှားစရာ စိတ်ဝင်စားစရာ ခေါင်းစဉ်တခုပါ။ အခု ကမ္ဘာမှာ ပညာရှင်တွေ တော်တော်လေး ကျယ်ကျယ်ပြန့်ပြန့် ကျယ်ကျယ်လောင်လောင် ပြောဆိုရေးသား ဆွေးနွေးနေကြပါပြီ။

ဒါကြောင့် ဒီဆောင်းပါးကို ရှေ့မဆက်ခင် မိတ်ဆွေတို့အနေနဲ့ အခြေခံ calculus သဘောတရားလေးဘာလေး အခြေခံ quantum mechanics ဗဟုသုတလေးဘာလေး အရင်ဆုံး ဖတ်ရှုလေ့လာ အားဖြည့်ထားလိုက်ပါဦးလို့ လေးလေးစားစား တိုက်တွန်းလိုက်ပါရစေခင်ဗျာ။ ကျွန်တော် ဆက်ရေးမယ့် Quantum Computing ရဲ့ တကယ့်အခြေခံမိတ်ဆက် အဆင့်လောက်အတွက်တော့ အဲဒါတွေ မဖြစ်မနေ လိုအပ်တယ်လို့ မဆိုလိုပါဘူး။ ဒါပေမယ့်...။

(ဆက်လက်တင်ပြပါမည်။)

ရွှင်လန်းချမ်းမြေ့ပါစေ။

[ခြိမ့်ထက်]

References:
http://www.doc.ic.ac.uk/~nd/surprise_97/journal/vol4/spb3/
http://en.wikipedia.org/wiki/Richard_Feynman

Sunday, August 7, 2011

Enterprise Software Architecture : II


အပိုင္း−၂
Factory Pattern

Factory Pattern ဆိုတာ Design Pattern တခုပါပဲ။ သူ ့ရဲ့ ရည္ရြယ္ခ်က္ကေတာ့ object creating ဆိုတဲ့ ရႈပ္ေထြးလွတဲ့ အပိုင္းကို တာဝန္ယူဖို ့ သက္သက္ပါ။ ဆိုလို တာကဗ်ာ ေရွ ့မွာကြ်န္ေတာ္တို ့ ေဆြးေနြးခဲ့တဲ့ Constructor Dependency Injection မွာ တုန္းကလို Client လုပ္ရမယ့္ အလုပ္ေတြကို ကိုယ္စားေဆာင္ရြက္ ေပးမယ့္ Stand alone class တခုပါပဲ။
သူက မ်ားေသာအားျဖင့္ static method ေတြကိုပဲ သံုးေလ့ရိွတယ္။ အဲဒီ method က client အတြက္ လိုအပ္တဲ့ object ကို ready-made ပံ့ပိုးေပးတယ္ေပါ့ဗ်ာ။

[စကားမစပ္
အခုေလ့လာေနတာက Enterprise level ဆိုေတာ့ ခု ေရးသားတင္ျပခဲ့တဲ့ / ေရးသားတင္ျပမယ့္ sample code ေတြရဲ့ UML diagram, Class diagram ေတြဘာေတြကို Reverse Engineering နည္းကို သံုးျပီး စိတ္ထဲက ဆဲြနိုင္ ျမင္နိုင္ တဲ့ အဆင့္လို ့ ယူဆထားပါတယ္။

ဒါ့အျပင္ static method နဲ ့၊ instance method စတာေတြ ဘာ ကြာတယ္ဆိုတာ ေတာ့ ဒီ အဆင့္မွာ ေကာင္းစြာ သိျပီးျဖစ္မယ္လို ့ ယံုၾကည္ယူဆထားပါတယ္။

မရွင္းတာရိွလည္း မွတ္ခ်က္ေလးဘာေလးေပးျပီး ေအာ္သြားေပါ့ဗ်ာ။ လိုအပ္သလို ျဖည့္စြက္ တင္ျပေပးပါမယ္။]

ကဲေျပာေနတာက ရႈပ္ေနဦးမယ္
ေဟာဒီမွာ ၾကည့္လိုက္ဗ်ာ...။

using IoCContainer.Model.Maps;
using IoCContainer.Model.PlaceOfInterests;

namespace IoCContainer.Model
{
    public static class TouristInformationServiceFactory
    {
        public static TouristInformationService getTouristServiceSatelliteMapEnglish()
        {
            return new TouristInformationService(
                new SatelliteMap(),
                new EnglishPlaceOfInterestDictionary());
        }
    }
}


အဲဒီေတာ့ဗ်ာ...
ဒီတခါ client က TouristInformationService ကို သံုးခ်င္ရင္ Map တို ့ PlaceOfInterest တို ့ ရဲ့ object ေတြကို သူကိုယ္တိုင္ create လုပ္ေနစရာမလိုပဲ [သိေတာင္ သိစရာမလိုပဲ] Factory class က တိုက္ရိုက္ေခၚသံုးလိုက္ရံုပဲေပါ့ဗ်ာ။
ေဟာဒီလို

using IoCContainer.Model;

namespace IoCContainer.ServiceConsumer
{
    public class ClientThatUsesService
    {
        TouristInformationService touInfoService;
        //..
        //..
        //..
        //..
        public void initializeServiceObject()
        {
            touInfoService = TouristInformationServiceFactory.getTouristServiceSatelliteMapEnglish();
            //..
            //..
            //..
        }

        //..
        //..
        //..
    }
}

ပိုျပီးေတာ့ loosely coupled ျဖစ္မလာေပဘူးလားဗ်ာ။
-Client ဟာ TouristInformaionService ကို ဘယ္လို create လုပ္ရမယ္ဆို တဲ့ အေသးစိတ္ေတြ သိစရာမလိုေတာ့ဘူး
-ျပီးေတာ့လည္း client ေပါင္းေျမာက္မ်ားစြာက အလြယ္တကူ လွမ္းေခၚျပီးသံုးလို ့ ရလာျပီ

Service Implementation နဲ ့ Client  က အခုအခါ ေတာ္ေတာ္ေလး Decoupling ျဖစ္သြားျပီ။ ဒါဆိုရင္ မိတ္ေဆြတို ့က ထင္မွာပဲ..အိုေကျပီေပါ့...။ အင္း ခက္တာက အရာတိုင္းဟာ ထင္သလို ထင္သေလာက္ အဆင္ေျပေလ့ မရိွတာပဲ။

ဘာလို ့လဲဆိုေတာ့ဗ်ာ..
ခုကြ်န္ေတာ္တို ့ sample implementation မွာ ေဆြးေနြးေနတာက
-Map ဆိုရင္ SatelliteMap တမို်းတည္း
-PlaceOfInterest ဆိုရင္လည္း EnglishPlaceOfInterest တမို်းတည္း အတြက္ပဲ ရိွေသးတာကိုး။

တကယ္တန္းကြ်န္ေတာ္တို ့ implement လုပ္ရမွာက
ကြ်န္ေတာ္တို ့ေရွ ့မွာေဆြးေနြးခဲ့သလို ဒီ service ဟာ
- နိုင္ငံေပါင္းစံု၊
- ေျမပံု ပံုသ႑ာန္ေပါင္းစံု ကို support လုပ္နိုင္ေအာင္ ေရးရမွာ။

Map ဆိုရင္လည္း SatelliteMap, RoadMap, GraphicMap, NonGraphicMap စသည္ျဖင့္ ပံုသ႑ာန္ အမို်းမို်း support လုပ္နိုင္ရမယ္...။ ပံုနဲ့ အၾကမ္းျဖင္းေျပာရရင္ ဒီလိုမို်းဗ်ာ...။








ျပီးေတာ့လည္း PlaceOfInterest ဆိုရင္လည္း နိုင္ငံေဒသအသီးသီးအတြက္ Support လုပ္ရမွာျဖစ္ေတာ့...ဒီလိုမို်းျဖစ္လာမယ္ဗ်ာ။ ဒါေတာင္ အကုန္မဟုတ္ေသးဘူးေနာ္...။ သေဘာေပါက္ရံု ျမင္သာရံု ေနာက္ နွစ္နိုင္ငံစာေလာက္ထည့္ လိုက္တာပဲရိွေသးတယ္။






ကဲ..အခုမိတ္ေဆြတို ့ ဘာကို သတိထားမိလာသလဲ။
[ဘာမွ သတိမထားမိပါဘူးဗ်ာ...ခင္ဗ်ားေျပာလို ့သာပါပဲ... :-) ;-) ]

ဒီလိုဗ်ာ..။
တကယ္လို ့ Client က
EnglishPlaceOfInterest ကို SatelliteMap နဲ ့လိုခ်င္တယ္။ အဲဒီအခါ sample code မွာျပထားသလို service object ကို create လုပ္လိုက္တာေပါ့။

ဒါေပမယ့္ client က SatelliteMap ကို ၾကည့္ ရတာ သိပ္မရွင္းဘူးျဖစ္ေနတယ္ဗ်ာ။ ခု တခါ သူလိုခ်င္တာ က
EnglishPlaceOfInterest ကို ပဲ RoadMap နဲ ့ ၾကည့္ခ်င္တယ္။

ဒါဆို ဘယ္လိုလုပ္မလဲ...။ Factory class ထဲမွာ ေဟာဒီလို function တခု တိုးလာမွာေပါ့...

public static TouristInformationService getTouristServiceRoadMapEnglish()
        {
            return new TouristInformationService(
                new RoadMap(),
                new EnglishPlaceOfInterestDictionary());
        }

တကယ္လို ့ NonGraphicalMap နဲ ့ လိုခ်င္ရင္

public static TouristInformationService getTouristServiceNonGraphicalMapEnglish()
        {
            return new TouristInformationService(
                new NonGraphicalMap(),
                new EnglishPlaceOfInterestDictionary());
        }



-ဒါ့အျပင္ ဒီ service ကို သံုးမယ့္ client ကလည္း သူလိုခ်င္တဲ့ object အေျခအေနေပၚမူတည္ျပီး သက္ဆိုင္ရာ function ကို ေျပာင္းျပီး ေခၚရမွာေပါ့...။

-ဒါေတာင္ ဒီဥပမာဟာ ဒါဟာ တနိုင္ငံတည္း အတြက္ပဲရိွေသးတယ္ဗ်။ နိုင္ငံေပါင္းစံု အတြက္ဆို So many different variants ေတြ ျဖစ္လာမွာေပါ့။

ဒါေၾကာင့္ ဒီ Factory pattern မွာ
၁။ Factory class ဟာ တကယ္ေတာ့ flow တူ ပံုစံတူတဲ့ object ေပါင္းမ်ားစြာအတြက္ (ခပ္ဆင္ဆင္)တူတဲ့ function ေပါင္းမ်ားစြာ ေရးေနရတယ္။ တကယ္ေတာ့ ဒါဟာ Dirty Job ေပါ့။
၂။ Client ကိုယ္တိုင္ လည္း Factory class နဲ ့ ခုအခါ tightly coupled ျဖစ္ေနျပန္ျပီ။ ဘာလို ့လဲဆိုေတာ့ဗ်ာ
client က သူလို တဲ့ object အေျခေနကို Well Aware ျဖစ္ရေတာ့မွာကိုး။ ဆိုလိုတာက GermanPlaceOfInterest ကို RoadMap နဲ ့လိုခ်င္တာလား၊ NewYorkPlaceOfInterest ကို GraphicMap နဲ ့ လိုခ်င္တာလား.....စသည္ျဖင့္ လိုအပ္ခ်က္ေပၚမူတည္ျပီး ...မတူကဲြျပားတဲ့ function ေတြကို Factory class က ေခၚရမွာကိုး...။


ဒါေၾကာင့္ ဒီအခက္အခဲ ကို ဘယ္လိုေက်ာ္လွြားမလဲဆိုတာကို Enterprise Software Architecture : III ရဲ့ Service Locator Pattern မွာ ဆက္လက္တင္ျပပါ့မယ္။

ရွြင္လန္းခ်မ္းေျမ့ပါေစ။

Saturday, August 6, 2011

Enterprise Software Architecture : I


(မွတ္ခ်က္။ ဒီအပိုင္းကို ေကာင္းေကာင္းနားလည္ သေဘာေပါက္နိုင္ဖို့ အတြက္ Dependency Injection Design Pattern ကို အရင္ဆံုး သိရိွနားလည္သေဘာေပါက္ျပီးျဖစ္သင့္ပါတယ္။)

အပိုင္း-၁
Constructor Dependency Injection
[Service provider class ၏ Constructor သို့၎အတြက္ လိုအပ္ေသာ Object မ်ားေပးသြင္းျခင္း]


ဆိုပါစို့ ကြ်န္ေတာ္တို့ဟာ အခု ကမၻာလွည့္ ခရီးသြားလာေရးလုပ္ငန္း တစ္ခုအတြက္ Application Service တခုေရးမယ္ဆိုပါစို ့ဗ်ာ။ အလြယ္ဆံုး အရိုးရွင္းဆံုး simple and plain structure ကိုပဲ စျပီး စဉ္းစားၾကည့္ၾကစို ့။ service name ကို TouristInformationService လို ့ အမည္ေပးလိုက္တာေပါ့။

၁။ ဒီ service မွာ ေနရာေဒသ Location ကို ျပမယ့္ ေျမပံု ပါမယ္။
၂။ ျပီးရင္ စိတ္ဝင္စားစရာ ေနရာေတြ အေၾကာင္းပါမယ္။ ဒါပဲ။


ကဲ အဲဒီေတာ့ ပထမဆံုး လိုအပ္တဲ့ ေျမပံု class ကို model အေနနဲ ့ create လုပ္လိုက္ဗ်ာ။ [ဘာေၾကာင့္ Interface ကို သံုးတာလဲ...ဒီ class ဟာ view လား model လား controller/service လား ဆိုတာေတြကို ေတာ့ သိျပီးျဖစ္မယ္လို ့ ေမွ်ာ္လင့္ပါတယ္။]


namespace IoCContainer.Model.Maps
{
    public interface IMap
    {
        void Set(Location currentLocation);
        void Add(PlaceOfInterests.PlaceOfInterest placeOfInterest);
        bool CurrentLocationIsNear(PlaceOfInterests.PlaceOfInterest placeOfInterest);
    }
}

namespace IoCContainer.Model.Maps
{
    public class SatelliteMap : IMap
    {
        public void Set(Location currentLocation)
        {
       
        }

        public void Add(PlaceOfInterests.PlaceOfInterest placeOfInterest)
        {
       
        }

        public bool CurrentLocationIsNear(PlaceOfInterests.PlaceOfInterest placeOfInterest)
        {
            return true;
        }
    }
}

ဒါကေတာ့ ဆိုပါစို ့Utility class တခုေပါ့ဗ်ာ။
namespace IoCContainer.Model
{
    public class Location
    {
    }
}
ျပီးရင္ သိတဲ့အတိုင္း ကြ်န္ေတာ္တို ့အထက္မွာ ေဆြးေနြးခဲ့သလိုပဲ စိတ္ဝင္စားဖြယ္ေနရာေတြကို စုစည္း ေပးမယ့္ class တစ္ခု create လုပ္ဖို ့လိုတာေပါ့။ အင္း..သူကလည္း data (database) နဲ ့ ဆိုင္တဲ့ေကာင္ဆိုေတာ့ ထံုးစံအတိုင္း model အုပ္စုထဲမွာ ပဲေပါ့ဗ်ာ။ ထားပါ။

namespace IoCContainer.Model.PlaceOfInterests
{
    public interface IPlaceOfInterestDictionary
    {
        IList<PlaceOfInterest> Places();
    }
}

အထူးသတိထားဖို ့က အခုကြ်န္ေတာ္တို ့ေရးေနတာက၊ Enterprise level application တစ္ခုအတြက္ လိုအပ္တဲ့ component တစ္ခု၊ service တစ္ခုကိုေရးေနတာ။ ဒီ service ကို တကမၻာလံုးသံုး လို ့ အဆင္ေျပရမယ္ ဆိုတာ မေမ့ပါနဲ ့။ ျမန္မာျပည္ကိုေရာက္ရင္ ျမန္မာျပည္ေျမပံု ျမန္မာျပည္ကစိတ္ဝင္စားစရာ ေကာင္းတဲ့ ေနရာေတြ၊ UK ေရာက္ရင္ UK ေျမပံု နဲ ့ UK ကစိတ္ဝင္စားစရာ ေကာင္းတဲ့ ေနရာေတြ၊ စသည္ျဖင့္ သက္ဆိုင္ရာ သက္ဆိုင္ရာ ကို execute လုပ္ေပးနိုင္ရပါမယ္။ ဒါေၾကာင့္....Maps ေတြ PlaceOfInterest ေတြ ဟာ မို်းကဲြေပါင္း မ်ားစြာ ပါမယ္ဆိုတာ သတိျပုပါ။

namespace IoCContainer.Model.PlaceOfInterests
{
    public class PlaceOfInterest
    {
    }
}

namespace IoCContainer.Model.PlaceOfInterests
{
    public class EnglishPlaceOfInterestDictionary : IPlaceOfInterestDictionary
    {
        public IList<PlaceOfInterest> Places()
        {
            return new List<PlaceOfInterest>();
        }
    }
}


ကဲအခု ကြ်န္ေတာ္တို ့ အေပၚမွာေရးခဲ့ျပီးျဖစ္တဲ့ ေျမပံုေတြ၊ သက္ဆိုင္စိတ္ဝင္စားစရာေနရာေတြကို လိုအပ္သလို စီမံခန္ ့ခဲြေပးမယ့္ service class တခု ေရးေတာ့မယ္ဗ်ာ။
web, web service, i-phone, android ..စတာတြမွာ run မယ့္ client application ေတြ ၊ တနည္းေျပာရရင္ ဒီ service class ကို သံုးစဲြမယ့္ service consumer class ေတြ က လွမ္း ေခၚမယ့္၊ လွမ္းသံုးမယ့္ class ေပါ့။

using IoCContainer.Model.Maps;
using IoCContainer.Model.PlaceOfInterests;
namespace IoCContainer.Model
{
    public class TouristInformationService
    {
        private IMap _map;
        private IPlaceOfInterestDictionary _placeOfInterestDictionary;


        public TouristInformationService(IMap map, IPlaceOfInterestDictionary placeDic)
        {
            this._map = map;
            this._placeOfInterestDictionary = placeDic;
        }
    }
}

ဒီ TouristInformationService class ထဲမွာ tourist information နဲ ့ ပတ္သက္တဲ့ function ေတြ အမ်ားၾကီးရိွမွာေပါ့ဗ်ာ။ ထားပါ..။ ဒါကေတာ့ auto understood ေပါ့။ အဲဒီ function ေတြကို ေခၚခ်င္ရင္ ဘာလုပ္ရမလဲ။ TouristInformationService object ကို create လုပ္ရမွာေပါ့။

ဘယ္သူကလုပ္မလဲ။ ေခၚမယ့္သူကလုပ္ရမွာေပါ့။
ဘယ္သူကေခၚမွာလဲ။ client ကေပါ့။

ဒါေၾကာင့္ client class မွာ TouristInformationService class ရဲ့ object ကို instantiate/create လုပ္ရမွာေပါ့။
ဒီမွာၾကည့္ဗ်ာ...

using IoCContainer.Model;
using IoCContainer.Model.Maps;
using IoCContainer.Model.PlaceOfInterests;

namespace IoCContainer.ServiceConsumer
{
    public class ClientThatUsesService
    {
        TouristInformationService touInfoService;
        //..
        //..
        //..
        //..
        public void initializeServiceObject()
        {
            IMap _map = new SatelliteMap();
            IPlaceOfInterestDictionary _placeOfInt = new EnglishPlaceOfInterestDictionary();

            touInfoService = new TouristInformationService(_map, _placeOfInt);
            //..
            //..
            //..
        }

        //..
        //..
        //..
    }
}
ကဲ..မိတ္ေဆြတို ့ ျမင္တဲ့အတိုင္းပဲ.

ကိုယ္သံုးမယ့္ TouristInformationService ရဲ့ object ကို instantiate/create လုပ္တဲ့အခါ
ေခၚတဲ့ သံုးတဲ့ client က
TouristInformationService အတြက္ လိုအပ္ေနတဲ့ ၊ TouristInformationService ကမီွခိုေနရတဲ့
ေျမပံုတို ့[Map] စိတ္ဝင္စားစရာေနရာတို ့[PlaceOfInterest] ဆိုတဲ့ object ေတြကို
TouristInformationService Constructor ကတဆင့္ လွမ္း ျပီး ထည့္သြင္းေပးလိုက္လို ့
ဒီလို Architecture ကို
Constructor Dependency Injection လို ့ေခၚတာပါ။

ကဲေကာင္းပါျပီ..
ဒါဆို ဘာျဖစ္လဲေပါ့...။
ကြ်န္ေတာ္တို့ဟာ ဒီ ေဆာ့ဖ္ဝဲကို ဒီဇိုင္းခ်တုန္းက
- service module ေတြ အခ်င္းခ်င္း loosely coupled ျဖစ္ေစဖို့
- service module တစ္ခုခ်င္းစီကို testing လုပ္နိုင္ဖို ့
- maintenance/ enhancement လုပ္တဲ့အခါ module တခုက တခုကို မထိခိုက္ေစပဲ တခုခ်င္းစီကို လြယ္လြယ္ကူကူ ျမန္ျမန္ဆန္ဆန္ လုပ္နိုင္ဖို ့ ဆိုတဲ့ ရည္ရြယ္ခ်က္ေတြနဲ့ လုပ္ခဲ့တာေလ..။

ခုေတာ့ ဒါေတြ သြားျပီေပါ့..။
ဘာေၾကာင့္လဲ....
Client class ဟာ Service class ရဲ့ လိုအပ္တဲ့ module ေတြ class ေတြနဲ ့ tightly coupled ျဖစ္ေနျပီေလ။
၁-ထိပ္ဆံုးက using statement ကိုၾကည့္လိုက္ ။ လိုတဲ့ assembly ေတြကို reference လုပ္ရတယ္။
၂- ျပီးေတာ့လည္း service class ရဲ့ dependency ျဖစ္ေနတဲ့ Map တို ့ PlaceOfInterest တို ့ရဲ့ object ေတြကို ပါ create လုပ္ေပးရတယ္။
၃- ဒါေၾကာင့္ SatelliteMap တို ့ EnglishPlacesOfInterestDictionary class တို ့မွာ တခုခု ေျပာင္းလိုက္တာနဲ ့ client code က break ျဖစ္သြားျပီ..။
၄- ဒါ့အျပင္ SatelliteMap တို ့ EnglishPlacesOfInterestDictionary တို ့ရဲ့ implementation ကို change ခ်င္ရင္ [ဆိုပါစို ့ဗ်ာ USASatelliteMap နဲ ့ USAPlacesOfInterestDictionary ကို ေျပာင္းသံုးမယ္ဆိုရင္] ဒီ Tourist Service ကို သံုးမယ့္ client code ေနရာတိုင္းမွာ လိုက္ change ေနရမွာေပါ့..။

ဒါဆိုရင္ ကိုယ့္ရဲ့ client code က ကိုယ္သံုးမယ့္ service အေၾကာင္းပါမက ကိုယ္သံုးမယ့္ service ရဲ့ dependency ေတြကိုပါ သိဖို ့လိုအပ္ေနျပီေကာဗို် ့....။ tightly coupled ဆိုတာ ဒါကိုေျပာတာေပါ့။

ဒါဆိုရင္ ဒီအခက္အခဲ ကို ဘယ္လိုေက်ာ္လွြားမလဲဆိုတာကို Enterprise Software Architecture : II ရဲ့ Factory Pattern မွာ ဆက္လက္တင္ျပပါ့မယ္။

ရွြင္လန္းခ်မ္းေျမ့ပါေစ။


Reference:
Professional Enterprise .NET [2009 - Wiley Publishing, Inc., Indianapolis, Indiana, USA] by Jon Arking and Scott Millett

Friday, May 27, 2011

Litany for Dictatorships

For all those beaten, for the broken heads,
The fosterless, the simple, the oppressed,
The ghosts in the burning city of our time ...

For those taken in rapid cars to the house and beaten
By the skilful boys, the boys with the rubber fists,
—Held down and beaten, the table cutting their loins,
Or kicked in the groin and left, with the muscles jerking
Like a headless hen’s on the floor of the slaughter-house
While they brought the next man in with his white eyes staring.

For those who still said “Red Front!” or “God Save the Crown!”
And for those who were not courageous
But were beaten nevertheless.
For those who spit out the bloody stumps of their teeth
Quietly in the hall,
Sleep well on stone or iron, watch for the time
And kill the guard in the privy before they die,
Those with the deep-socketed eyes and the lamp burning.

For those who carry the scars, who walk lame—for those
Whose nameless graves are made in the prison-yard
And the earth smoothed back before morning and the lime scattered.

For those slain at once. For those living through months and years
Enduring, watching, hoping, going each day
To the work or the queue for meat or the secret club,
Living meanwhile, begetting children, smuggling guns,
And found and killed at the end like rats in a drain.

For those escaping
Incredibly into exile and wandering there.
For those who live in the small rooms of foreign cities
And who yet think of the country, the long green grass,
The childhood voices, the language, the way wind smelt then,
The shape of rooms, the coffee drunk at the table,
The talk with friends, the loved city, the waiter’s face,
The gravestones, with the name, where they will not lie
Nor in any of that earth. Their children are strangers.

For those who planned and were leaders and were beaten
And for those, humble and stupid, who had no plan
But were denounced, but grew angry, but told a joke,
But could not explain, but were sent away to the camp,
But had their bodies shipped back in the sealed coffins,
“Died of pneumonia.” “Died trying to escape.”

For those growers of wheat who were shot by their own wheatstacks,
For those growers of bread who were sent to the ice-locked wastes,
And their flesh remembers their fields.

For those denounced by their smug, horrible children
For a peppermint-star and the praise of the Perfect State,
For all those strangled or gelded or merely starved
To make perfect states; for the priest hanged in his cassock,
The Jew with his chest crushed in and his eyes dying,
The revolutionist lynched by the private guards
To make perfect states, in the names of the perfect states.

For those betrayed by the neighbors they shook hands with
And for the traitors, sitting in the hard chair
With the loose sweat crawling their hair and their fingers restless
As they tell the street and the house and the man’s name.

And for those sitting at table in the house
With the lamp lit and the plates and the smell of food,
Talking so quietly; when they hear the cars
And the knock at the door, and they look at each other quickly
And the woman goes to the door with a stiff face,
Smoothing her dress.
“We are all good citizens here.
We believe in the Perfect State.”
And that was the last
Time Tony or Karl or Shorty came to the house
And the family was liquidated later.
It was the last time.
We heard the shots in the night
But nobody knew next day what the trouble was
And a man must go to his work. So I didn’t see him
For three days, then, and me near out of my mind
And all the patrols on the streets with their dirty guns
And when he came back, he looked drunk, and the blood was on him.

For the women who mourn their dead in the secret night,
For the children taught to keep quiet, the old children,
The children spat-on at school.
For the wrecked laboratory,
The gutted house, the dunged picture, the pissed-in well,
The naked corpse of Knowledge flung in the square
And no man lifting a hand and no man speaking.

For the cold of the pistol-butt and the bullet’s heat,
For the rope that chokes, the manacles that bind,
The huge voice, metal, that lies from a thousand tubes
And the stuttering machine-gun that answers all.

For the man crucified on the crossed machine-guns
Without name, without resurrection, without stars,
His dark head heavy with death and his flesh long sour
With the smell of his many prisons—John Smith, John Doe,
John Nobody—oh, crack your mind for his name!
Faceless as water, naked as the dust,
Dishonored as the earth the gas-shells poison
And barbarous with portent.
This is he.
This is the man they ate at the green table
Putting their gloves on ere they touched the meat.
This is the fruit of war, the fruit of peace,
The ripeness of invention, the new lamb,
The answer to the wisdom of the wise.
And still he hangs, and still he will not die,
And still, on the steel city of our years
The light fails and the terrible blood streams down.

We thought we were done with these things but we were wrong.
We thought, because we had power, we had wisdom.
We thought the long train would run to the end of Time.
We thought the light would increase.
Now the long train stands derailed and the bandits loot it.
Now the boar and the asp have power in our time.
Now the night rolls back on the West and the night is solid.
Our fathers and ourselves sowed dragon’s teeth.
Our children know and suffer the armed men.

Stephen Vincent Benét (July 22, 1898 – March 13, 1943)
[American author, poet, short story writer, and novelist]


From Selected Works of Stephen Vincent Benét
(New York: Holt, Rinehart and Winston, 1955)

"ဘယာနကဂါထာ"

ဒီကာလဆိုးအတွင်းက
မီးကျွမ်းမြို့တော်ကြီးရဲ့
နှိပ်စက်ညှင်းပန်းခံရသူတွေ
ဦးခွံကြေမွကွဲ သွေးချင်းချင်းရဲနေတဲ့သူတွေ
အကာအကွယ်မဲ့သူတွေ
လူသာမန်တွေ
ဖိနှိပ်ခံရသူတွေ
မကျွတ်လွတ်သေးတဲ့ ဝိဉာည်တွေ
အားလုံးအတွက်….။

ငရဲအိမ် ကိုဦးတည်
ဒလကြမ်းမောင်းသွားတဲ့ကားပေါ် ပစ်တင်ခံရတဲ့သူတွေ
(သူတို့ကို)
ကျွမ်းကျင်သူ တွေက ရိုက်နှက်
ရာဘာလက်အိပ်စွပ်လက်တွေနဲ့ထိုးကြိတ်
မြေပေါ်လှဲချ ကန်ကျောက်
ခုံပေါ်တင် အသားလှီးဖြတ်
အကြောဆွဲဆတ်ဆတ်တုန်
သားသတ်ရုံမြေပြင်ပေါ်က ခေါင်းပြတ်ကြက်လို (ဖြစ်တော့မှ)
သွေးဆုတ်ဖြူရော် ငေးကြောင်မျက်လုံးတွေနဲ့နောက်တယောက်ကိုခေါ်သွင်း…။

"ကြွပါခင်ဗျာ"…
"မင်းတြားကြီးဘုန်းကြီးပါစေ" ဆိုသူတွေ
ရဲစွမ်းသတ္တိမရှိသော်ငြား..ရိုက်နှက်နှိပ်စက် ခံ သူတွေ
ကျွတ်ထွက်သွားတဲ့သွားကို သွေးနဲ့ရော တိတ်တဆိတ်ထွေးထုတ်ခဲ့သူတွေ
သံမဏိပေါ် ကျောက်တုံးပေါ်အိပ်စက်ခဲ့သူတွေ
အခွင့်ကောင်းကိုချောင်း
မသေခင် ကင်းစောင့်ကိုသတ်ခဲ့သူတွေ
မျက်တွင်းအဝီစိမှာ မီးတောက်နေသူတွေ…
သူတို့တွေအားလုံးအတွက်….။

ဒဏ်ရာအမာရွတ်တွေနဲ့လူတွေ
ခြေဆာထော့နဲ့ နေသူတွေ အတွက်
အကျဉ်းထောင်ဝင်းထဲက အမည်မဲ့သေတွင်းများ
မိုးမသောက်ခင် မြေပြင်ကိုပြန်ညှိ
ဖုံး ဖိ အုပ် နင်း ထုံးဖြူခင်း..။

အလျင်အမြန် ကွက်မျက်ခံရသူတွေနဲ့
နှစ်လရှည်ကြာ သည်းခံ စောင့်ကြည့် မျှော်လင့်
အလုပ်သွား
အသားလေးနဲနဲရဖို့တန်းစီ
လျို့ဝှက်တိုင်ပင်
သားသမီးပွားစီး
လက်နက်ခိုးသွင်း သူတွေလည်း
နောက်ဆုံးတော့
ရေမြောင်းထဲက ကြွက်တွေလို သုတ်သင်ခံရ။

လွတ်မြောက်ထွက်ပြေးသွားသူတွေ
နိုင်ငံရပ်ခြားမြို့ကြီးများရဲ့ အခန်းကျဉ်းလေးတွေမှာနေထိုင်နေသူတွေ
သူတို့အမြဲတွေးနေသမျှတွေက….
ကိုယ့်တိုင်းပြည်အကြောင်း
မျက်ခင်းစိမ်းတွေအကြောင်း
ကလေးဘဝက ပြောစကား ဆိုစကား တွေအကြောင်း
လေသင်းနံ့လေးအကြောင်း
နေထိုင်ခဲ့တဲ့အခန်းလေးအကြောင်း
ကော်ဖီသောက်ခဲ့တဲ့စားပွဲလေးအကြောင်း
စားပွဲထိုးလေးတွေအကြောင်း
သူငယ်ချင်းမိတ်ဆွေတွေနဲ့ ပြောဆိုခဲ့တဲ့အကြောင်း
ကိုယ်ချစ်တဲ့ကိုယ့်မြို့အကြောင်း
အမည်ရေးထိုးထားတဲ့ အုတ်ဂူ ကမ္မည်းကျောက်ပြားတွေအကြောင်း
သူတို့သေခွင့်မရမယ့် သုဿန်အကြောင်း
သူတို့နေခွင့်မရတဲ့ မြေအကြောင်း
နောက်ဆုံး....
သားသမီးရင်းတွေနဲ့ သူစိမ်းပြင်ပြင်ဖြစ်သွားခဲ့ရတဲ့အကြောင်း..။

စီစဉ်ခေါင်းဆောင်သူတွေကိုညှင်းပန်း
မစီစဉ် ရိုးအသူတွေကိုစွပ်စွဲ
ဒေါသမျိုချ ဟားတိုက်ခဲ့သူတွေအပါအဝင်
ကြောင်းရင်းမဲ့စွာ အဝေးမှာ “စခန်းသွင်း”
မကြာခင်တော့ပြန်ပို့
အလုံပိတ်ခေါင်းတလားတွေနဲ့
စာသားတစ်ကြောင်းရေး
“အအေးမိ၍ ကွယ်လွန်”…..။
“ထွက်ပြေးရင်းသေဆုံး”..…။

Saturday, April 30, 2011

ညမဲ့ကြယ်

ငါကိုယ်တိုင်မပိုင်ဆိုင်လိုတော့ပြီ
လွတ်လပ်ဘဝတွေ….။

ငါကိုယ်တိုင်မနာယူလိုတော့ပြီ
မြင့်မြတ်တရားသံ….။

ဘာတွေကို ယုံပြီး အသက်ဆက်ရှင်နေလဲ
ငါပိုင်ဆိုင်တာ
ရင်ဗလာဟင်းလင်းပြင်။


ညမဲ့ကြယ်စင်
လောင်ကြွမ်းခြင်း မုန်းတီးငြီးငွေ့နေပြီ..။
ငါ့ ယုံကြည်ချက်
ငါ့ ကို အဆိပ်တက်။
[ခြိမ့်ထက်-၂၀၁၁]