The Composite Application Guidance for WPF and Silverlight is designed to help you more easily build enterprise-level Windows Presentation Foundation (WPF) client applications.
5. 28 September, 2009 Composite Application Library – Prism v2 – Introduction 5 Design concepts – View Discovery With the view discovery approach, modules can register views (or presentation models) against a particular named location. When that location is displayed at run time, any views that have been registered for that location will be automatically created and displayed within it.
6. 28 September, 2009 Composite Application Library – Prism v2 – Introduction 6 Design concepts – View Injection In the view injection approach, views are programmatically added or removed from a named location by the modules that manage them. To enable this, the application contains a registry of named locations in the UI and a module can look up one of the locations using the registry and then programmatically inject views into it.
7. 28 September, 2009 Composite Application Library – Prism v2 – Introduction 7 Design concepts – Commanding In a composite application, separated presentation patterns are used for decoupling the view from the presentation logic. In this case, user actions within the view have to be routed to appropriate handlers outside of the view. In addition, the UI elements associated with those actions often have to be enabled or disabled based on state changes within the application. Windows Presentation Foundation (WPF) introduces the concept of commands to support these kinds of interactions. UI elements can be bound to a command, which handles the handler execution logic. The UI element can then execute the command as the user interacts with it in the UI. The UI element will also be automatically enabled or disabled as the underlying command becomes enabled or disabled. The default WPF RoutedUICommand mechanism requires event handlers to be defined in the receiving UI element or in parent UI elements above it in the visual tree. In a composite application, command routing cannot follow the visual tree. Additionally, there are complex scenarios in composite applications where the handling of a command is delegated to child commands. To overcome this constraint, you can use WPF to create custom ICommands so that you can directly route the command to handling logic independently of the visual tree. Two common approaches are delegation and composition.
8. 28 September, 2009 Composite Application Library – Prism v2 – Introduction 8 Design concepts - CommandDelegation The command delegation approach uses a command that delegates its handling logic, either through events or delegates, where it can be handled externally by a class such as a presenter, service, or controller. This provides the benefit of making this handling logic more testable, by not having code in the view's code-behind. The command requires two handlers: one for the Execute method and one for the CanExecute method. Whenever the Execute or CanExecute methods are called on the command, the handlers are called either through the event being raised or the delegate being invoked
9. 28 September, 2009 Composite Application Library – Prism v2 – Introduction 9 Design concepts – Command Composition The command composition approach is a variation of command delegation. In this approach, a composite command delegates its handling logic to a set of loosely coupled child commands
10. 28 September, 2009 Composite Application Library – Prism v2 – Introduction 10 Design concepts – Eventing - Event aggregation In a composite application, components, such as presenters, services, and controllers, residing in different modules, often need to communicate with one another based on state changes or application logic. This is a challenge because of the decoupled nature of a composite application because the publisher has no direct connection to the subscriber. Additionally, there may be threading issues because the publisher is on a different thread than the subscriber.
11. 28 September, 2009 Composite Application Library – Prism v2 – Introduction 11 Design concepts - Modularity Modularity is designing a system that is divided into a set of functional units (named modules) that can be composed into a larger application. A module represents a set of related concerns. It can include a collection of related components, such as features, views, or business logic, and pieces of infrastructure, such as services for logging or authenticating users. Modules are independent of one another but can communicate with each other in a loosely coupled fashion.
12. 28 September, 2009 Composite Application Library – Prism v2 – Introduction 12 Design concepts – Modularity – Advantages Simplified application architecture. Developing and/or deploying modules independently. You can independently version modules. You can develop and test modules in isolation. You can have modules developed by different teams. Loading modules from different locations. Minimizing download time. When the application is not on the user's local computer, you want to minimize the time required to download the modules. To minimize the download time, only download modules that are required to start-up the application. The rest are loaded and initialized in the background or when they are required. Minimizing application start-up time. To get part of the application running as fast as possible, only load and initialize the module(s) that are required to start the application. Loading modules based on rules. This allows you to only load modules that are applicable for a specific role. An application might retrieve from a service the list of modules to load.
13. 28 September, 2009 Composite Application Library – Prism v2 – Introduction 13 Design concepts – Layered approach to module design Define the goals for the modular design Decide how you are going to partition your modules and define your module's responsibilities The most common approach is to partition your application so that each module has its own functional area, such as Customers or Orders Define the communication patterns between the modules.
14. 28 September, 2009 Composite Application Library – Prism v2 – Introduction 14 Design concepts – Bootstrapper The bootstrapper is responsible for the initialization of an application built using the Composite Application Library. In a traditional Windows Presentation Foundation (WPF) application, a startup Uniform Resource Identifier (URI) is specified in the App.xaml file that launches the main window. In an application created with the Composite Application Library, it is the bootstrapper's responsibility to create the shell or the main window. This is because the shell relies on services, such as the Region Manager, that need to be registered before the shell can be displayed.