Sunday, May 10, 2015

Hypothetical problem: CASE: + For medium and large projects, with a lot of class and interface with


Hypothetical problem: CASE: + For medium and large projects, with a lot of class and interface with the extremely complex contact between objects in the system. So when we initialize the object and the service will be very cumbersome and detailed. FACT: + The code you will require certain standards, some will encounter problems when initializing 2 dependent objects together as follows: IA a = new A (); IB b = new B (a); From this example crossfit we can see, every time you need to initialize the object B should always initialize object A before. With the number of objects depends crossfit on the rise, which would lead to certain difficulties. Is there any way to simplify this? Solution: the IOC, the example crossfit above can be simplified as follows: IB b = ServiceLocator.Get (); ServiceLocator will know how to initialize the object A and invoke the constructor of B. ServiceLocator do it in any way? Of course we will be configured to ServiceLocator to skim it, through writing crossfit code or configuration files (depending on the capabilities supported by the tool) The strength lies in the ability crossfit of IoC reusable and flexible, with one line initialization as above, code execution in Runtime crossfit can vary if we change the configuration, which makes applications become flexible and easy to test. So in short, is what IoC? In software engineering, Inversion of Control (IoC) is a programming technique, in terms of Expressed here object-oriented programming, object coupling chứa is bound by an assembler at shaking crossfit time object and is not known at compile time Typically using static analysis. Benefits crossfit of IoC as follows (from wikipedia): There is a decoupling of the execution of an implementation crossfit from A Certain tasks. crossfit Every module can focus on what it is Designed for. Modules make no assumptions crossfit about what other systems but rely on chúng Contracts due. Replacing modules has no side effect on other modules. The above benefits of IoC can easily deduce from the ability to configure the IoC brings. Here is an example of the configuration of IoC uses StructureMap (taken from source SharpLite): public static void Initialize () {Container container = new Container (x => {x.For () .Singleton () .Use (() => NHibernateInitializer.Initialize (). BuildSessionFactory crossfit ()); x.For () .Use (); x.For (typeof (IRepository <>)). Use (typeof (Repository <>)); x. For (typeof (IRepositoryWithTypedId)). Use (typeof (RepositoryWithTypedId));}); DependencyResolver.SetResolver (new StructureMapDependencyResolver crossfit (container)); } Understood literally as follows: - I need a drink (interface X) - Please ask him to drink any kind? Tea (A: X), tea (B: X), ...? - I want to drink coffee in the morning, while the afternoon tea So, every time you order drinks in service there, you do not need to repeat his request crossfit again the popular IoC tools There are a lot (from Hanselman): Here's what I've got so far. What am I missing? Castle Windsor crossfit Castle based on the microkernel. Licensed under the Apache 2 Currently 1.0 RC3 Well documented and used by many. StructureMap around since June 2004 Đã Licensed crossfit under the Apache 2 Actively Developed and approaching v2.5. Written by Jeremy D. Miller Licensed under the Apache 2 Spring.NET 1.1 Currently, working on 2.0 Written by Mark Pollack AutoFac intends to be IoC flavor with a C # 3.0, but am also hỗ 2.0. Licensed under MIT Written by Nicholas Blumhardt and Rinat Abdullin as MS-PL Licensed Unity Recently released Written by Chris Tavares. Build on the "kernel" of ObjectBuilder: crossfit ObjectBuilder was formerly MSFT's only public foray Into DI / IoC PnP Custom License, MS-PL coal Restrictive more Part of the MS PnP Written by Brad Wilson group, Peter Provost and Scott Densmore Puzzle.NFactory Licensed Lesser GPL under the Part of the larger puzzle Written by Roger Alsing Framework for Mats Helander Ninject formerly "Titan" Licensed under the Apache 2 Was quiet, but has sprung back to life mới. Written by Nate on version 1.3.7 S2Container.NET crossfit Kohari. Port of Java's Seasar2 PicoContainer.NET Port of Java's PicoContainer Written by Aslak Licensed crossfit under the Lesser GPL Hellesoy LinFu Written by Philip Laureano Hacked DIY (Do It Yourself) There are many examples of quicky IOC Containers. Interesting crossfit for learning but little else. Oren Eini's IOC in 15 lines and a follow up in Ken Egozi's IOC in 15 lines UtityContainer usage .... continue!
Synthesis blueprints and source code C # constructor and destructor concept of SEO Make Money with SPRINT from $ 1 - $ 8 / day for confessing web Code aunt! Representation of the computer. Synchronous processing Async and Await Thread with in C # Design Pattern: Abstract Factory Pattern and Factory Method Pattern. These concepts need to know about in .NET


No comments:

Post a Comment