Top Banner
Introduction to Microsoft Prism Tomaš Maconko
21
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction to Microsoft Prism

Introduction to Microsoft Prism

Tomaš Maconko

Page 2: Introduction to Microsoft Prism

Issue

• We need a HUGE WPF desktop application

• Application must be module-based (plugin-based)

• Modules are developed by different teams in different countries

• Team work is not synchronized

• Application must be tested periodically

Page 3: Introduction to Microsoft Prism

Solution

• Easy, but totally not acceptable – decline the project

• Hard, but hardly acceptable – write your own module management infrastructure

• Medium and acceptable – use an already implemented framework for modular applications

Page 4: Introduction to Microsoft Prism

Microsoft Prism

• Used in applications consisting of multiple modules

• Contains module management infrastructure

• Provides navigation between views, even if navigation is performed between views from different modules

• Allows application to evolve and enables easy-maintenance

• Currently used in WinRT, WPF, Silverlight and Windows Phone apps

Page 5: Introduction to Microsoft Prism

Reusability

• Allows components and services to be developed, tested and integrated into one or more applications

• Reuse of unit-tested components that can be easily discovered and integrated at run time through dependency injection

• Modules can encapsulate application-level capabilities that may be reused across applications

Page 6: Introduction to Microsoft Prism

Extensibility

• Allows components to be more easily integrated or replaced with alternative implementations at run time

• Provides the ability to decompose an application into modules that can be independently updated and deployed

• Many of the components in the Prism Library itself can also be extended or replaced

Page 7: Introduction to Microsoft Prism

Flexibility

• Allows to extend the application with new capabilities, that can be easily developed and integrated

• Allows WPF applications to be developed using common services and components, allowing the application to be deployed and consumed in the most appropriate way

Page 8: Introduction to Microsoft Prism

Team Development

• Allows separate teams to develop and even deploy different parts of the application independently

• Minimizes the cross-team dependencies and allows teams to focus on:• Different functional areas: UI design, business logic implementation,

and infrastructure code development

• Different business-level functional areas: profile, sales, inventory, or logistics

Page 9: Introduction to Microsoft Prism

Quality

• Allows common services and components to be fully tested and made available to the development teams

• Allows development teams to focus on their application requirements instead of implementing and testing infrastructure code

Page 10: Introduction to Microsoft Prism

Where to use it?

Page 11: Introduction to Microsoft Prism

Module management infrastructure

• Load modules immediately or on demand depending on configuration

• There can be no direct/static references between projects

• Modules can be configured through C# code or in configuration file

• Can register each module separately or read all modules from directory

Page 12: Introduction to Microsoft Prism

Configuration is simple

Page 13: Introduction to Microsoft Prism

Module initialization sequence

1. When application starts BaDemo.Common is initialized as it is static reference.

2. Next BaDemo.Main is loaded, because is should be initialized immediately after startup.

3. A. If the user requested BaDemo.Orders, then both BaDemo.Orders and BaDemo.Items would be initialized, as BaDemo.Orders depends on BaDemo.Items.

4. If the user requested BaDemo.Items, then it is initialized without BaDemo.Orders.

BaDemo

BaDemo.Main

BaDemo.Items

BaDemo.Common

BaDemo.Orders

1. On application start

2. On application start 3a. On requested

4. On requested

3b. On BaDemo.Orders module requested

Page 14: Introduction to Microsoft Prism

Other features

• Model-View-ViewModel pattern utilities

• Navigation handling

• Dependency Injection support

• Event aggregation

Page 15: Introduction to Microsoft Prism

Model-View-ViewModel

• INotifyPropertyChanged implementation

• ICommand implementation

Page 16: Introduction to Microsoft Prism

Navigation handling

• IRegionManager • INavigationAware

Page 17: Introduction to Microsoft Prism

Dependency injection support

• Registration • Usage

• Registration can be done in Bootstrapper class or in each module

• Each container provides its own dependency management mechanism:• MEF uses attributes to specify the

exported and imported dependencies• Unity container requires registration

of types and can automatically resolve instances

• And so on...

Page 18: Introduction to Microsoft Prism

Event aggregation

Page 19: Introduction to Microsoft Prism

Conclusions

• Prism seems to be usable and proper framework for in modular application development

• It contains many tools for easy module management, navigation between modules

• It provides additional tools for MVVM, DI, Event Aggregation and other patterns

• It’s Open Source

Page 20: Introduction to Microsoft Prism

Sources

• Prism CodePlex: http://compositewpf.codeplex.com/SourceControl/latest

• MSDN Prism Guide: https://msdn.microsoft.com/en-us/library/ff648465.aspx

• Demo in GitHub: https://github.com/tmaconko/BaDemo

Page 21: Introduction to Microsoft Prism

Keep #EnjoyITContact me, if you have questions:

[email protected]

• www.ba.lt