Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there a default module loading mechanism in prism? What happens if I don't load my modules in code or by discovery?

What I have tried:

I can still call the module's methods like any other class (after referencing the library), so what's the catch?
Posted
Updated 25-Jul-18 7:07am

If you are able to reference ALL libraries you need at build time then you do not have to use modules as defined in Prism. In this case (and if your requirements are simple) then using Prism modules can be overkill.

Now, consider the situation where your application allows your users to create/write their own plugins. You cannot know in advance what plugins your users will write and therefore you cannot reference these plugins when you build your application. This is where Prism modules fill the gap and allow your application to specify by configuration or discovery what other modules must loaded and initialized at runtime.

I do not have a lot of experience with Prism but from what I recall it does not have a default loading mechanism. If you chose to use MEF then you use declarative attributes to define what and how assemblies are loaded/initialized. In this case, you can, but do not have to, implement the IModule interface (e.g. look at the StockTrader RI sample code which does not implement IModule). If you do not use MEF or reference libraries in your projects then you must implement the IModule interface and define the modules in XAML, a configuration file, code or discovery.
 
Share this answer
 
v3
Comments
nmeri17 25-Jul-18 9:54am    
That's interesting. Thank you. Besides the scenario you posted, I don't see how often it'll be feasible to drop components or fragments of an application into it during runtime. I thought it was a generic platform for composing software written by several disparate programmers.
Prism was designed for enterprise applications where it is not uncommon to have thousands of modules and even thousands of developers. Prisms features (e.g. assisting with with MVVM, GUI, navigation, communication between modules) are critical to large scale applications.

As I mentioned, for small applications, Prism can definitely be overkill and even unnecessarily complicate the implementation. If your application consists of only a few views and/or assemblies/modules and you choose to ignore best practices (e.g. do not make use of MVVM, add business logic to the code behind file, do not use TDD/BDD, etc) then when problems occur they are still manageable.
 
Share this answer
 
Comments
nmeri17 25-Jul-18 18:56pm    
Alright. I understand now. Yet, it isn't a bad idea to get up to speed with it, just in case my next employer requires it. Best not to learn on the job.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900