WHITEPAPER M&M Application Platform for WPF Author: Sven Rieger Created on: 2015-04-10 Version: 1.0 Modular W indows desktop applications need a well -defined architecture. Modularity has to be supported throughout the whole application and its architecture. This implies a modular UI and the separation of the application into several modules providing diff erent functionality. These modules contain logic as well as UIs shown inside the application’s main UI. Engineering systems like the fdtCONTAINER application from M&M Software GmbH are typical examples. Figure 1 shows the fdtCONTAINER application screen. Figure 1 - fdtCONTAINER a pplication The UI is based on state-of-the art elements like the ribbon, known from Microsoft Office 2013. It presents the available commands to the user. The first button of the ribbon opens the so called backstage view. It provides basic functionality such as creating a new file or project, open, save, file info, application info and so forth. Content specific ribbon tabs are added depending on the context of the active document window. Document and tool windows are shown in the area below the ribbon. Their content is usually provided by the modules. This is typical for this particular kind of applications and therefore addressed by the architecture. Reference Architecture How does the M&M Platform for WPF architecture look like? Figure 2 gives an overview of the reference architecture. The platform is based on the mainstream technologies of the .NET 1 / 6 WHITEPAPER M&M Application Platform for WPF framework. This make it possible to provide long term support. Microsoft Extensibility Framework (MEF) supporting loose coupling and Windows Presentation Foundation (WPF) for the UI are two important parts of the .NET framework to mention at this point. On top of the technology part the framework is located. It is a mix of open source and commercial components building up the basic framework. These components are used to build up the application’s frame which manages and integrates the modules. Shell View Bootstrapper Module 1 Module 2 Module n Localization Extension Cinch MEFed MVVM Microsoft Patterns & Practices Prism ActiPro Ribbon and Docking log4net The application specific modules are based on this framework as illustrated w ith gray boxes. These modules comprise the application specific parts like e.g. the device management. The “Shell View - Bootstrapper” is a required module. It defines the application’s UI frame and is responsible for the application startup. .Net Freamework 4 or 4.5 / WPF / MEF Figure 2 - Individu al W PF Refere nce Architecture Modularity and loose coupling Modular extension is achieved by using the Microsoft Extensibility Framework (MEF). MEF supports the creation of loose coupled and extensible applications which is one of the key quality attributes in this architecture. Having a modular approach allows adding and removing functionality by adding or removing modules. Since modules are more or less independent from each other modules ca n be developed in parallel without influencing each other too much. This results in a faster time to market, assumed, that the project team size can be scaled. A modular approach has also its advantages when developing product lines. The frame and the basic modules can be re-used in different variants of the product. The various products within the 2 / 6 WHITEPAPER M&M Application Platform for WPF product line may consist of several specific modules combined with a selection of common modules. UI with WPF In this architecture the UI is built up using W PF which allows to create UIs with a good user experience. Using the styling mechanisms of WPF it is possible to customize the UI according to the company’s corporate identity and the defined UI style guide. For example, the blue parts of the window shown in Figure 1 could be colored using the company colors. WPF also clearly distinguishes between UI and logic. To support this the Model View View -Model patterns is used (see Figure 3). It separates the UI (View) from the complex business logic (Model). UI logic is located in the View-Model. The views are connected to the view models by using the data binding mechanisms provided by WPF. View View-Model Model Data Binding Figure 3 - MVVM pattern Testability The modular approach and the MVVM pattern provides a solid basis for more effective unit and integration tests. This guarantees the product quality and ensures a good maintainability of the developed software solution. Microsoft Patterns & Practices Prism as basis Microsoft Patterns & Practices Prism provides a generic framework to build loosely coupled, modular W PF applications. It provides e.g. event managers and named UI regions to decouple the modules. It has been used successfully for several applications at M&M Software GmbH and was therefore the first choice for the M&M Ap plication Platform for WPF. Loose coupling in Prism is realized by dependency injection. There is a choice between Unity and MEF. For this basis architecture MEF has been chosen, because it’s already included in the .Net Framework and fulfills the needs required for this architecture. ActiPro Ribbon and Docking ActiPro Ribbon and Docking controls have been chosen for the ribbon and docking functionality. Like Prism they also have been used successfully in several projects. The Ribbon control behaves like the Ribbons known from Microsoft Office. The docking control provides the same behavior as known from Visual Studio. Another advantage of the docking control is the good integration with Prism. It supports the Prism regions out of the box. This has the advantage that the docking area can be used like any other Prism area and no extra implementation is needed. Cinch with MEFedMVVM The Cinch library supports the development of MVVM -based applications. It consists of several base and helper classes that make life easier when developing view models. There is no benefit in developing your own base classes. 3 / 6 WHITEPAPER M&M Application Platform for WPF Loose coupling is also an important topic when dealing with view models. MEFedMVVM is a library that helps to develop MVVM applications and keep the view mode l loose coupled from the view. Internally MEFedMVVM uses MEF to achieve this. The view model is registered with a name and the view resolves the view model by the view model name. Hence the view and the view model do not have any dependency beside this nam e. Data from the view model is displayed in the view using W PF’s original data binding mechanism. Localization Most of the applications are shipped internationally. Hence localization is an important topic. In many applications, users shall be able to swit ch the language without restarting the application. In our architecture the “WPF Localization Extension” component is used. This component is very flexible. It provides an interface to add own localization providers. Hence it’s possible to get the resource strings from a custom database, if required. Resx files, usually used in .net, are supported by default. Centralized Logging The centralized application logging is accomplished using log4net, which is a very powerful logging component. It provides a nice API and good configuration options. Hence it’s possible to fully customize logging according to the project needs. Log4net also provides so called appenders. They define, how the log entries are handled, e.g. persist to file or database. Conclusion This reference architecture defines a foundation for modular applications with Microsoft Office 2013 style. It has successfully been used by fdtCONTAINER application, dtmINSPECTOR and an engineering tool developed for one of our customers. Summary: Microsoft Patterns & Practices Prism is good to build loosely coupled applications. Modular design and the usage of MVVM ensures a good maintainability and unit testing basis. Product lines can be built based on the modular design. Prism, ActiPro, Cinch, Localization Extension and log4net, together provide a solid reference architecture for modular Microsoft Office 20013 style applications. Specific application architectures are built by adding application specific building blocks like e.g. Device Management. Although reuse of object oriented code may fail frequently, reusing reference architectures saves time and effort while increasing quality. 4 / 6 WHITEPAPER M&M Application Platform for WPF Boxes Used Technologies Technology / Component Source Microsoft Patterns & Practices Prism http://compositewpf.codeplex.com/ ActiPro Ribbon and Docking http://www.actiprosoftware.com/products/ controls/wpf/ribbon http://www.actiprosoftware.com/products/ controls/wpf/docking Cinch https://cinch.codeplex.com/ MEFedMVVM http://mefedmvvm.codeplex.com/ WPF Localization Extension https://wpflocalizeextension.codeplex.com/ Log4net http://logging.apache.org/log4net/ Advantages and limitations Advantages o Basic UI frame styled like Office 2013 with dockable windows o Loose coupled modules o Covers cross-cutting concerns Localization Logging Limitations o Supports W indows Desktop Applications only. Mobile devices are out of scope. Suitable for Engineering Systems Configuration Tools 5 / 6 WHITEPAPER Company Profile M&M M&M Software stands for innovation, competency and quality. Being more than 25 years in business, M&M has gained the reputation as a reliable partner for many renowned customers worldwide. Our vast industry know-how is reflected in a wide range of innovative and unique software solutions that we have developed for and together with our customers in the factory and process automation, maritime technology, mechanical engineering, building automation and energy technology. M&M is the competent service provider for all matters concerning software products in the industrial automation. Our service portfolio includes Management & Technology Consulting, Software Development, Quality Assurance, IT Operations & Services and Software Mainte nance & Support. We mainly focus on solutions for Human Machine Interfaces (HMI), device integration, engineering systems and web applications. The company’s headquarter is in St. Georgen in Germany’s Black Forest region. Our subsidiary in Suzhou near Shanghai/China was established in 2005. There we do not only serve the upcoming markets in Asia, but also offer offshore development services to our customers in Europe and America in proven M&M quality to significant price advantages. At the end of 2012 M&M established its subsidiary in Hanover. This location enables us to serve our customers in the north of Germany even better . 6 / 6 M&M Software GmbH Industriestr. 5 78112 St. Georgen GERMANY +49(0)7724/9415-0 Fax +49(0)7724/9415-23 Email: [email protected] Internet: www.mm-software.com Registered Office: St.Georgen, Germany Registry Court: Freiburg HRB 602021 Directors: Erwin Mueller, Klaus Huebschle, Andreas Boerngen
© Copyright 2024