yeafee@夜飛郎

          it's usually better to solve problems with simplicity and finesse rather than muscle.

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            33 隨筆 :: 3 文章 :: 2 評論 :: 0 Trackbacks
          Understanding inversion of control

                  IoC(Inversion of control)是Spring的心臟,聽著感覺它比較晦澀。其實(shí)它遠(yuǎn)不像聽著的那樣難懂。事實(shí)上,在你的工程中引入IoC之后,你會(huì)發(fā)現(xiàn)你的代碼會(huì)變得非常簡樸,更易于理解和測試。
                 但是,究竟什么是IoC呢?
          Injecting dependencies                        
          In an article written in early 2004, Martin Fowler asked what aspect of control is being inverted. He concluded that it is the acquisition of dependent objects that is being inverted. Based on that revelation, he coined a better name for inversion of control: dependency injection.

          Traditionally, each object is responsible for obtaining  its own references to the objects it collaborates with (its dependencies). As  you'll see, this can lead to highly coupled and hard-to-test code.Applying IoC, objects are given their dependencies at creation time by some external entity that coordinates each object in the system.That is, dependencies
          are injected into objects. So, IoC means an inversion of responsibility with regard
          to how an object obtains references to collaborating objects.

           IoC in action                                        

                
          posted on 2005-12-13 15:47 @yeafee 閱讀(359) 評論(0)  編輯  收藏 所屬分類: OpenSource
          主站蜘蛛池模板: 水城县| 涟源市| 贺州市| 永州市| 偏关县| 阿鲁科尔沁旗| 蕉岭县| 海伦市| 垫江县| 津南区| 义乌市| 屏山县| 营口市| 濮阳县| 博爱县| 巴塘县| 香河县| 洪泽县| 含山县| 乐昌市| 德兴市| 江门市| 舟山市| 福清市| 三河市| 寻甸| 澳门| 务川| 涿州市| 滦南县| 浦县| 仪征市| 丽江市| 如皋市| 理塘县| 深州市| 蚌埠市| 瑞金市| 班戈县| 金昌市| 松原市|