Some general questions/Remarks

Jan 2, 2011 at 10:11 PM

Hi Daniel,

I'm using Calcium and some other Prism based projects (such as the StockTraderRI in the Prism4 release) to jump in the deep end learning to work with WPF/CAL/IoC and related technologies.

When comparing your work with Calcium with the mentioned StocktraderRI I noticed a few things. For one, the StocktraderRI was apparently moved to MEF as opposed to Unity for taking care of dependency injection. The choice between MEF and Unity greatly determines the way things can be implemented and there are a few things I do not or only partially understand about these differences:

1) As far as I can tell you spent quite some effort to devise a system where you can discover modules within assembly files in directories (using your CustomModuleCatalog). Am I correct in assuming that this is because Unity does not offer functionality similar to DirectoryCatalog/AggregateCatalog offered by MEF? Ergo, that in this respect, MEF is a bit "easier"?

2) In the stocktrader RI, as far as I can tell, all services are injected into the constructors of the different Modules/Viewmodels. You rely heavily on ServiceLocatorSingleton. Could you tell me something more about why you chose to go this route? I know there is a lot of "DependencyInjection vs. ServiceLocation" literature online but for the most part these articles are generally quite "academic". I have some difficulty wrapping my head around some of it out of the context of a real application.

3) As an exercise I would like to try and leverage some of the Calcium code to rely on MEF instead of unity. I would like to start by grafting some things like the IFileService/FileService into a module that I could plug into the StockTraderRI project. Is this feasible or are there some aspects of the services that you wrote that are essentially requiring use of Unity?

4) One last thing I do not understand is why a service like FileService  has the following line: static readonly ILog log = LogManager.GetLogger(typeof(FileService)); If I want to log some aspects of the Service during its operation, why dont I inject a common logger instance from the container? I am confused because I thought a logger is already defined in the bootstrapper.

As you can tell I am probably not very well versed in the different topics but there is just so much to learn, therefore any answers to my questions above would help me out a lot!

Keep up the good work, Calcium looks like a very useful project, not only for Application development but certainly also for learning about ways to use all these technologies! 

Jan 4, 2011 at 7:05 AM

Hi Kris,

Thanks a lot for your message, and kind words.

1. When I implemented the module resolution code, MEF wasn't an option. It may be that it would be a better fit.

2. I prefer service location over DI for services. Otherwise, I find that you end up having to pass around instances that should be available everywhere. E.g., ILog. This adds to much noise for my liking. I also find dependency resolution failures easier to diagnose when using service location.

3. I'd say go for it! I'd love to see what you come up with.

4. That's how log4net works. I intend to remove the dependency on log4net.