I put together a wholesale e-commerce site for a client using the ASP.NET MVC Framework instead of the usual ASP.NET Webforms. If using ASP.NET webforms, I probably would have used the Web Client Software Factory because the website itself is a classic composite web application. Daring to be bold, however, this website was also a perfect candidate for the ASP.NET MVC Framework and I really like the simplicity of MVC and the ability to create your own ControllerFactory and then use your favorite IoC Tool to inject dependencies into those controllers.
ModuleInitializers
Like the WCSF, I use the concepts of Business Modules and ModuleInitializers:
public interface IModuleInitializer
{
void Init();
void Load(IContainer container, RouteCollection routes);
}
Each module has the ability to register its controllers and services into the module container as well as add routes. You might do the following:
public EcommerceModule : IModuleInitializer
{
public void Init() {}
public void Load(IContainer container, RouteCollection routes)
{
container.Register<IProductCatalog,ProductCatalog>();
container.RegisterController<ProductsController>("Products");
// Add Any Routes...
}
}
If you are interested in understanding ModuleInitializers from a WCSF point-of-view, you can check out the following screencast:
Hierarchy of IoC Containers
Just like in the WCSF, there is a root IoC Container that essentially contains global services and then each business module has its own IoC Container, which is a child container of the root container. Therefore as shown above, the EcommerceModule has its own IoC Container that gets passed in for controller and service registration. It is that IoC Container that is used in the Custom Controller Factory to inject dependencies into the ProductsController. Of course any dependencies that are not fulfilled by the module IoC Container will try to be fulfilled by the root IoC Container.
As it so happens I am using Unity from Microsoft Patterns & Practices in the background, but I could easily replace it with Windsor or Spring at the drop of a hat ( it is pluggable ). You can read more about Unity Hierarchy here:

If you are interested in using Unity in the ASP.NET MVC Framework, you can check out these screencasts:
I will note that the way I show creating controllers and injecting their dependencies in the screencast is not the same way I do it with my Composite ASP.NET MVC “Framework”. When you are getting into registering controllers in separate modules and a hierarchy of IoC Containers you have to do things a bit differently :) That being said, most ASP.NET MVC Framework Applications can use Unity as mentioned in the screencasts.
Check out SCSF, Prism and Caliburn Examples - Similar Techniques
I haven't looked at the Fourth Drop of Prism yet, but previous examples showed off good use of Unity for composite WPF Applications. I also found out about Caliburn - An MVP Framework for WPF Composite Applications that apparently shows off composite WPF Guidance. And, of course, you can always look at the newly released SCSF for Visual Studio 2008.
A lot of really nice inspiration for developing your composite applications, whether they be smart clients, ASP.NET Webform, ASP.NET MVC, or WPF.
I get a call on Monday afternoon from a new client to do a couple of presentations on Tuesday on the Web Client Software Factory and Unity from Microsoft Patterns & Practices. No big deal technically as I have given many presentations on those subjects. The question going through my mind is do I want to do this on the new MacBook Pro which is untested for presentations or do I want to go back to the old reliable, but slow Dell XPS laptop? Hmmm...
A smarter person would have opted for the Dell, but I decided to go boldly with the MacBook Pro :) I then decided to go one further. How about I use iWork Keynotes instead of Microsoft Powerpoint? I forsee myself running vmware Fusion in Unity Mode with Visual Studio 2008 and Keynotes running together flawlessly on the desktop. Of course, I also didn't no squat about Keynotes and already had some perfectly good Powerpoint Presentations on WCSF and Unity done.
Again, a smarter person would have stayed with Powerpoint, but I am a sucker for a little challenge, so I fired up Keynotes and started to move a lot of the content I had in Powerpoint to Keynotes by hand. While doing this, a few things struck me:
- Keynotes is incredibly simple to use. Without reading the help file, I was instantly productive.
- Keynotes creates gorgeous presentations. Using the stock templates and settings created a nice set of presentations.
- Creating transitions, build ins, build outs, and actions was easy enough for anyone to create more animated presentations.
Keynotes actually made putting together a presentation enjoyable! I always hated using Powerpoint. Always. I am not sure what is different, but Keynotes just made it fun. Maybe it is because the interface is simple and more intutive to use. Maybe it is because the templates, assets, and tools just deliver nicer results more easily. Maybe it is because I just feel a bit more creative now that I have a Mac. I don't have a clue, but what I can tell you is that for the first time I felt really proud of my presentation slides. There weren't a lot of slides as no developer, especially myself, wants to be in Keynotes when he can be playing in Visual Studio. However, those slides that were there looked really, really good if I do say myself.
If you do a decent amount of presentations and have a Mac, I recommend checking out Keynotes if you haven't already. From now on when you see me at a presentation, it will be the MacBook Pro and Keynotes all the way baby :)
Related Posts