Recently I found a really cool YouTube technical video, “Unit of Work & Repository Framework” by a Microsoft MVP named Long Le. One of the most amazing things about this 21:30 long video is how much ground he covers in it. Here is a link to his blog about the video (link to the YouTube video is in the blog entry):
Here are the main topics he touches on:
- Entity Framework Power Tools
- Uow & Repo Framework
- Generating EF Mappings and POCO’s
- Upgrading the stack to EF 6.2
- Basic Customer CRUD Use Case with MVC Scafolding Template w/ Async
- Refactoring the CustomerController to use UoW & Repo Framework w/ Async
- Why the ICustomerService Approach?
- Why Commit Unit of Work Outside the Service vs. versa
- Quick Examples with Eager Loading, Filter, and Sorting
What is more amazing than the number of topics he covers in 21+ minutes is that he manages to do so in a very clear, understandable way.
But what is even better is that the framework he has created is available on CodePlex, for anyone to download and use (and change/extend for their own requirements). The CodePlex link is:
The parts of the video I found most useful were when he was actually in the code, and showing how the generic, UOW repository layer over Entity Framework was injected into an MVC controller using the Unity dependency injection container.
The dependency injection pattern in general, whether one implements it manually or uses an Inversion of Control container such as Microsoft Unity, Ninject, or Castle Windsor (to list a few of the major ones) is a pattern that all senior developers/architects should consider utilizing in any large/complex software applications to reduce coupling of software objects/components/layers. For one thing, it can make testing (particularly mocking) much easier – but utilizing dependency injection is another whole discussion.
One word about Unity… Having done a bit of research comparing those three particular IoC containers, I am comfortable nowadays using Unity because its most recent version, Unity 3, seems pretty solid (I wouldn’t have used Unity 1.0, but then isn’t that typical of Microsoft software products!). Ninject has not been updated since March 2012, which seems like a long time at this point. To be fair to any other products like Castle Windsor and a couple of others, I haven’t checked them out thoroughly – but at this point I am fine with sticking with the Microsoft component (and of course there are the obvious benefits of doing that).
But to summarize, I would highly recommend watching Long Le’s video. If you are a software developer and/or architect, I guarantee you will be impressed.