Practical solutions for comparing and merging models
Author: Dr. Konrad Wieland, LieberLieber Software
Contribution – Embedded Software Engineering Congress 2015
The increasing complexity and ever-shorter release cycles of modern embedded software systems necessitate the parallel development of different versions. Adding to this challenge is the fact that these systems are developed by increasingly large and distributed teams. When using a model-driven approach, such teams must be able to work efficiently on parallel versions of a model. The advantages of version control systems have been successfully leveraged for years in source code generation. Their most important function is the comparison and merging of different versions. Traditional approaches use line-based and text-based applications for this purpose, which are insufficient for graphical models. This article demonstrates how models can be practically compared and merged to enable efficient version control.
Throughout the entire software development process, a wide variety of software artifacts undergo numerous changes. Tools that support this evolution of artifacts are essential [2] [3]. Therefore, techniques have been and continue to be developed under the umbrella term Software Configuration Management (SCM) to support or even enable these change processes. Version control systems (VCS) fall into this category and originated as early as the 1970s.
Version control systems pursue the following three goals:
- They archive different versions that have resulted from changes, in order to be able to undo changes at any time and revert to an older version.
- They help to manage different "branches", i.e., parallel development paths, that are required by the development of software variants.
- You can coordinate the parallel development of (distributed) teams.
In all three points, the comparison and/or merging of versions is of central importance. With the last point, the number of requirements and the complexity increase due to native integration into a version control system. Basically, two approaches can be distinguished here, which I will briefly introduce in the next paragraph.
Pessimistic and optimistic versioning
In the so-called pessimistic versions The individual artifacts are locked to prevent them from being modified simultaneously. This completely avoids conflicts, but waiting times are almost unavoidable.
At the optimistic versioning In contrast, the same artifact is processed simultaneously or in parallel (see Figure 1, PDFBoth developers perform a "checkout" and work on a copy in parallel. Before the second developer can save their changes, these changes must be merged with the changes already made by the first developer. This process is divided into four steps:
- Identifying the changes between the two versions
- Detection of conflicts between changes
- Automatic or manual resolution of these conflicts
- Creating a new version that (ideally) includes all changes from both versions
Comparing models
With the rise of modeling and model-driven software development in recent years, models are no longer just used for brainstorming and analysis, but are an integral part of all stages of the development process. These models are usually deployed under version control and are further developed in parallel by a development team. Since this is a very complex and laborious process with conventional tools, the industry's demand for tools for version control and parallel development of models has grown increasingly louder [1] [4].
However, the line- and text-based approaches that have become established for source code have proven insufficient. Rather, only a free-granular approach makes this possible. 3-way comparison algorithm, This three-way comparison, which takes the graph structure of the models into account, allows for an accurate comparison between two models. Only this three-way comparison for models, which considers the base version, makes it possible to calculate the changes in the respective model versions in a way that the user can understand. For each version, it is necessary to calculate which property of a model element has changed (Update), which element has been moved (Move), which element has been added (Insert), which element is referenced (Use), or which element has been deleted (Delete).
The calculation and display of potential conflicts between two versions is an integral part of a merge tool. A categorization of the potential conflicts is shown in Figure 2 (see PDF) shown [5].
Representation of changes and conflicts
Conflicts between two versions must be resolved to achieve a consolidated version. While various strategies have been developed to automate this process, manual resolution by a user is often unavoidable. For this to work, however, changes and conflicts must be presented in a way that is easily understandable for the user. Since changes to graphical models usually also occur at the diagram level, it is particularly important to display these changes within the diagram itself. Figure 3 (see PDF) shows a screenshot of the Dear Model Versioner, which calculated the differences between two Enterprise Architects1 The model is listed side-by-side in a fine-grained manner and visualized in the respective diagram.
One of the biggest challenges in this process is performance (speed and resource consumption), especially when comparing models with hundreds of thousands of model elements and connectors. Particularly when combined with a version control system like Subversion or Git, it's crucial to ensure that developers checking in their changes to the repository aren't hindered in their daily work.
Furthermore, the correctness of the model must be ensured when merging parallel changes to prevent any distortions during this complex process. Under no circumstances should the model become inaccessible in the modeling editor after merging. Although semantic inconsistencies or visual imperfections in the layout of merged diagrams are also important considerations, they should not be prioritized at this stage.
Summary
Version control systems are indispensable in modern system and software development. However, traditional line-based or text-based approaches are insufficient for supporting models. Instead, a tool is needed that provides a precise comparison between (graphical) models and calculates conflicts with fine granularity to efficiently and user-friendly manage different model versions. Furthermore, native integration with existing version control systems is essential to support modelers in their daily work. In addition to performance, the user-friendly display of diagram changes and the monitoring of model validity are crucial components of a modern model version control system.
_____________________________________________
1 Enterprise Architect is a modeling tool from Sparx Systems that can be used to create models in UML, SysML, or BPMN, among other languages. Integration with a VCS is possible, however, versioning from XML exports is limited to pessimistic versions.
Bibliography and list of sources
[1] L. Bendix, P. Emanuelsson: Requirements for Practical Model Merge – An Industrial Perspective. MODELS 2009: pp.167-180, 2009.
[2] J. Estublier, D. Leblang, A. Hoek, R. Conradi, G. Clemm, W. Tichy, and D. Wiborg-Weber. Impact of software engineering research on the practice of software configuration management. ACM Transactions on Software Engineering and Methodology, vol. 14, no. 4, pp. 383-430, 2005.
[3] Mens, Tom: A State-of-the-Art Survey on Software Merging. IEEE Transactions on Software Engineering, vol. 28, no. 5, pp. 449-462, 2002.
[4] K. Wieland, G. Fitzpatrick, G. Kappel, M. Seidl, M. Wimmer: „Towards an Understanding of Requirements for Model Versioning Support“; International Journal of People-Oriented Programming (IJPOP), 2; 1 – 23, 2011.
[5] K. Wieland, P. Langer, M. Seidl, M. Wimmer, G. Kappel: „Turning Conflicts into Collaboration – Concurrent Modeling in the Early Phases of Software Development“; Computer Supported Cooperative Work: The Journal of Collaborative Computing, 22 (2013), 2-3; 181 – 240.
Modeling – MicroConsult Training & Coaching
Do you want to bring yourself up to date with the latest technology?
Then find out more here MircoConsult offers training courses/seminars/workshops and individual coaching on the topic of modeling/embedded and real-time software development.
Training & coaching on the other topics in our portfolio can be found here. here.
Modeling – Expertise
Valuable expertise in modeling/embedded and real-time software development is available. here Available for you to download free of charge.
You can find expertise on other topics in our portfolio here. here.
