.NET Technologies Blueprint: Business Object Frameworks – Dependency Injection

1. Traditional Object Oriented Programming encourages us to use classes for our business objects. Dependency Injection frameworks take us a few steps  forward down these roads.  Always use interface to create Business Objects models. This ensures implementation may be changed at later stage regardless of initial code. Ensures better decupling between software layers


2. Dependency Injection frameworks enables us to supply an external dependency to a software component
    - Better testability
    - Greater flexibility
    - Out of the box infrastructure for Dependency Injection pardigm
    - Enables us using various resources for actual implementation (ranging from other classes to external configuration files)
    - May be confusing at first, requires a more experienced programmer
    - Some frameworks tend to be over configurable (too much XMLs)




3. There are 4 types of Dependency Injection:
    - Constructor Injection, most common – enables “injecting” a different implementation into objects based on their interfaces
    - Property Injection – also called “Setter injection”  - Attach dependency through setter properties
    - Method Injection – Inject implementations via methods (use interface based parameters)
    - Field Injection – Define member fields of interface-based type



4. Possible frameworks range from dedicated frameworks such as Ninject to a component inside a full-blown framework, such as Spring.NET and MS Unity



5. Ninject – Lightweight, fast tool, focuses only on Inversion of Control & Dependency Injection
    Recommended when Dependency Injection is required, won’t supply any other services
    - Lightweight, won’t bloat your project with its code
    - Focuses only on Dependency Injection, thus very fast
    - Requires referencing Ninject.Core everywhere in your code to add [inject] attributes
    - Uses type binding in code (i.e. references and not configuration files) , thus, binding cannot be altered after the application is compiled.



6. Unity Application Block – Part of MS Patterns & Practices, a lightweight extensible Dependency Injector
    - Open source
    - Part of EntLib
    - Seems to rely too much on XML Configuration



7. Spring.NET - Inversion of Control & Dependency Injection are only a part of the deal. Spring.NET covers many more areas, such as:

    AOP, Unit Testing,    Data Access (Spring.NHibernate), Web services and Web Extensions.

    Heavy, everything included – use when you need more than just Dependency Injection
    - Familiar to Java Converts
    - Clean (if you are used to) Syntax for Wiring
    - Many out-of-the-box components
    - Wasn’t invented at Microsoft
    - Can look like magic at the beginning
    - Now has MS burn compiler (MEF)
    -Configuration intensive – lots of XML

Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at info@tikalk.com