|
Just this morning I managed to get my hands on some new bits that I think people might be interested in. If you're familiar with the concepts behind Inversion of Control and Dependency Injection (just a special type of IoC really) then you might want to keep reading.
Basically what a DI framework lets you do is decouple the dependencies within your application. Rather than a controller having code in it that is manually new'ing up a reference to the view and the model, a DI framework lets your controller simply state that it needs a view of a certain type and a model of a certain type. The wiring up is then done for you automatically either at compile-time or runtime (or a little of both, depending on what you're using).
The problem with this approach is that it requires developers and architects to actually figure out what dependencies each piece of their application needs. Worse, this often requires developers to do some hard thinking about how they want to split their application into components to maximise re-use, increase efficiency, and create a highly resilient application. These are all admirable goals but let's face it - it sounds an awful lot like work.
What we really need is the next level of Dependency Injection.... Predictive Dependency Injection. Instead of us having to be explicit about the code on which other code depends, Predictive Dependency Injection (PDI) works by figuring out what you're going to need and when you're going to need it, and putting it there.
Say, for example, you're building an online banking application that allows customers to look at their transaction history and perform basic transactions like withdrawals, transfers, etc. Rather than having to go through the tradiational (hard work!) process of figuring out what components you're planning on building and how they all inter-relate with each other, now you can let PDI do the work for you.
Basically it works like this:
var bankingApplication = PredictiveUnity.Resolve<WhatIWant>();
bankingApplication.DoWhatIWant();
The PDI container will figure out what kind of app you're building and, using a combination of an advanced code generation tool (acronym: ESP) and other predictive heuristics the PDI container will make available to you an instance of an object that provides the backing functionality for your application. It creates several methods on this generated object that will perform the tasks that you need.
This doesn't sound all that interesting, right? But here's where it becomes a useful tool: you don't need to figure out what you need at the time you're coding it. The DoWhatIWant() method will figure out what the app needs to do and do it. The developer no longer has to be burdened with the hard work of design, analysis, or the tedium of manually typing C# code.
I recommend PDI for every developer who is currently thinking that tasks like design and coding are old-school and there's something better out there.
You can download the first CTP of Predictive Dependency Injection here .