posts - 37,comments - 7,trackbacks - 0
          1. Both FM an AFM create objects. But FM do it through inheritance and AFM through object composition. 
                To create objects using FM, you need to extends a class and override a factory method. the whole point of the FM Pattern is that your're using a subclass to do your own creation for you. In that way, clients only need to know the abstract type they are using, the subclass worries about the concrete type. So,  in other words, FM keep clients decoupled from the concrete types.
                AFM provides an abstrct type for creating a family of products. Subclasses of this type define how those products are produced. To use the factory, your instantiate one and pass it into some code that is written against the abstract type. So, like FM, the clients are decoupled from the actual concrete products they use.

          2. AFM group together a set of related products
          3. AFM often use factory methods to implement it's concrete factories. 

          4. use  AFM whenever you have families of products you need to create and you want to make sure your clients create products that belong together. use FM to decouple your client code from the concrete classes you need to instantiate, or if you don't know ahead of time all the concrete classes you are going to need , just subclass and implement the factory method.
           
          posted on 2005-08-12 11:03 Dave 閱讀(156) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
          博客園   IT新聞   Chat2DB   C++博客   博問  
           
          主站蜘蛛池模板: 中卫市| 苏尼特右旗| 旅游| 高唐县| 浦北县| 夏津县| 长汀县| 大城县| 云安县| 贵港市| 金川县| 千阳县| 大关县| 呼玛县| 水城县| 尼玛县| 湛江市| 江川县| 绥宁县| 五大连池市| 海盐县| 吴堡县| 德钦县| 贡嘎县| 凉山| 封开县| 芦山县| 龙游县| 陇南市| 大余县| 伊通| 休宁县| 界首市| 威信县| 阿克苏市| 兴和县| 张家口市| 赤峰市| 桂林市| 茶陵县| 宜章县|