Friday 27 July 2012

PRISM : An Introduction

What is PRISM?


Prism (or Composite WPF) is a framework provided by Microsoft to help build composite WPF ,Silverlight and Window Phone 7 applications.
It has mechanisms for

  • UI composition,
  •  Module management and 
  • Dependency injection.
Prism uses the design concepts of 
  • Separation of concern
  • Loose Coupling

 Prism helps you to design and build applications using loosely coupled components that can evolve independently but which can be easily and seamlessly integrated into the overall application. These types of applications are known as composite applications.

Advantages of PRISM

  • Create an application from modules that can be built, assembled, and, optionally, deployed by independent teams using WPF or Silverlight.
  • Minimize cross-team dependencies and allow teams to specialize in different areas, such as user interface (UI) design, business logic implementation, and infrastructure code development.
  • Use an architecture that promotes reusability across independent teams.
  • Increase the quality of applications by abstracting common services that are available to all the teams.
  • Incrementally integrate new capabilities.

Important terms in PRISM

Shell:The main window of a WPF application or the top-level UserControl of a Silverlight application where the primary UI content is contained.

Region :A named location that you can use to define where a view will appear. Modules can locate and add content to a region in the layout without exact knowledge of how and where the region is visually displayed. This allows the appearance and layout to change without affecting the modules that add the content to the layout.

Region Manager:The class responsible for maintaining a collection of regions and creating new regions for controls. The RegionManager finds an adapter mapped to a WPF or Silverlight control and associates a new region to that control.

Regions allow you to define named placeholders in your main view (the “Shell”). When you initialize your module, you can inject views (e.g. user controls) into these placeholders by specifying their name. This helps separate the application layout from specific views, and allows injecting other views at run time (such as add-ins).

Region Context is a technique that can be used to share context between a parent view and child views that are hosted in a region. The RegionContext can be set through code or by using data binding XAML.


Bootstrapper:The class responsible for the initialization of an application built using the Prism Library.

Composite application: A composite application is composed of a number of discrete and independent modules. These components are integrated together in a host environment to form a single, seamless application.

Event Aggregator:A service that is primarily a container for events that allows publishers and subscribers to be decoupled so they can evolve independently. This decoupling is useful in modularized applications because new modules can be added that respond to events defined by the shell or other modules.

Module:A logical unit of separation in the application

Module Catalog:Defines the modules that the end user needs to run the application. The module catalog knows where the modules are located and the module's dependencies.

Module Manager:The main class that manages the process of validating the module catalog, retrieving modules if they are remote, loading the modules into the application domain, and invoking the module's Initialize method

View Discovery:A way to add, show, or remove views automatically in a region by associating the type of a view with a region name. Whenever a region with that name displays, the registered views will be automatically created and added to the region.

View Injection: A way to add, show, or remove views programmatically  in a region by adding or removing instances of a view to a region. The code interacting with the region does not have direct knowledge of how the region will handle displaying the view.


PRISM Architecture



When to Use View Discovery vs. View Injection

View discovery is a automatic and simple approach to composing views and getting them displayed in a region. In general, View discovery is used , but you can use view injection if you need one of the following:

  • Explicit or programmatic control over when a view is created and displayed, or when you need to remove a view from a region, for example, as a result of application logic.
  • To display multiple instances of the same views into a region, where each view instance is bound to different data.
  • To control which instance of a region a view is added (for example, if you want to add customer detail view to a specific customer detail region). Note that this scenario requires scoped regions described later in this topic.

What PRISM cannot do

  • Occasional connectivity and data synchronization
  • Service and messaging infrastructure design
  • Authentication and authorization
  • Application performance
  • Application versioning
  • Error handling and fault tolerance

No comments:

Post a Comment