4-example.tex 7.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. \section{Example}
  2. \label{sec:example}
  3. As a simple example of our approach, we present here the implementation of an instantiation model management operation.
  4. The operation is invoked on an element in a metamodel that has to be instantiated, using the existing model to which the instantiation should be added.
  5. Current tools implement this using code written in the implementation language and hardcoded in the tool, even though their tool supports a neutral language (\textit{e.g.}, OCL).
  6. A normal neutral language is unfit for this purpose for several reasons:
  7. \begin{enumerate}
  8. \item Any representable model in the tool might become subject to instantiation, so we don't want to define the operation over the linguistic metamodel defined by the user.
  9. If we were to do this, only instances of that exact metamodel could ever be instantiated.
  10. Creating a new metamodel would also require users to reimplement all instantiation operations over and over again, to make them applicable to the model used.
  11. Most of the time, instantiation is very similar, so a default should be provided.
  12. By implementing this operation at the physical level, tools avoid this problem as they now work on the internal representation, which is identical for all models.
  13. \item Instantiating a model element is an invasive operation, which can greatly disturb the linguistic dimension by, for example, breaking conformance to the linguistic metamodel.
  14. Implementing instantiation based on the linguistic metamodel, defined by the user, would therefore also be unwise, as conformance might break halfway through the operation, making the function not applicable anymore.
  15. \item Strict metamodelling prevents users from crossing between levels.
  16. Even if the previous two problems were to be solved, a single model (the instantiation algorithm) cannot have links to both the model (to add the instantiated element), the metamodel (to read out the element to instantiate), and even the metametamodel (to find subtyping information).
  17. \end{enumerate}
  18. With our approach, each of these reasons is solved as follows:
  19. \begin{enumerate}
  20. \item Instead of shifting the algorithm to the physical dimension to get access to the physical representation, we shift the physical representation to the linguistic dimension as $\mathit{LTM}_\perp$.
  21. This way, the low-level representation of the model is also an explicit instance, for which each possible model conforms to one and the same metamodel: $\mathit{LTM}_\perp$.
  22. If the retyping operation is defined using $\mathit{conformance}_\perp$, it will be applicable to every possible model.
  23. \item The type of a model is not visible in normal circumstances, as it is part of the conformance check.
  24. It is indeed even dangerous to change the type of a model, while operating on that specific type.
  25. By operating on a different type, however, of which it is known that the model will always conform to it, there are no risks involved at all.
  26. While it might be possible that some of the other previous conformance relations are broken (\textit{e.g.}, to a user-defined metamodel), $\mathit{conformance}_\perp$ is not invalidated by the operation as it holds by definition.
  27. \item As previously shown, our approach just changes views to $\mathit{conformance}_\perp$, in which strict metamodelling is still valid, but it doesn't actually restrict anything, since every element is at the same level.
  28. \end{enumerate}
  29. The algorithm is related to how models are represented internally: all models are subgraphs of a single coherent graph.
  30. This format of model representation is itself already level-crossing, as there are edges for both navigation and instantiation.
  31. As it contains level-crossing links, it is an invalid model when viewed through an ordinary linguistic typing relation.
  32. It is, however, viewable and even modifiable using $\mathit{conformance}_\perp$, as the model completely complies to $LTM_\perp$.
  33. During the execution of the algorithm, the model is viewed not through the usual conformance relation, but through the $\mathit{conformance}_\perp$ relation.
  34. As such, the model can be modified as if it were merely a graph, without any additional semantics or imposed restrictions.
  35. Apart from just allowing any kind of structural change, inconsistencies in the usual conformance relation are also possible: cardinalities, multiplicities, potencies, and so on, can all be invalidated as their semantics is not checked at this level.
  36. Operations defined by the user, using the normal linguistic conformance relation, will just reinterpret the graph to the usual linguistic dimension, thus again checking all additional constraints such as cardinalities.
  37. We use this code to instantiate a new petri net place, as specified by the petri nets metamodel.
  38. The example is visualized in Figure~\ref{fig:example}.
  39. Figure~\ref{fig:example_A} indicates the problem with the instantiation algorithm: it accesses itself and three different modelling levels:
  40. the model level to write out the instantiated model,
  41. the metamodel level to read out the allowed attributes and all constraints,
  42. and the metametamodel level to know about inheritance links and how to handle them.
  43. Accessed elements are highlighted in the figure, indicating that the algorithm requires access (and thus, links) to all these levels.
  44. It is therefore impossible to add it at either of these levels: adding it to one level would cause violations for the other levels.
  45. By taking the $\mathit{conformance}_\perp$ view, the modelling hierarchy changes from Figure~\ref{fig:example_A} to Figure~\ref{fig:example_B}, in which there are no level-crossing links anymore.
  46. In Figure~\ref{fig:example_B}, all access are again highlighted, but are now within the same level in the modelling hierarchy.
  47. There is therefore no longer any violation of strict metamodelling.
  48. \begin{figure*}
  49. \centering
  50. \begin{subfigure}{0.4\textwidth}
  51. \centering
  52. \includegraphics[width=\columnwidth]{figures/example_problem.pdf}
  53. \caption{Using normal conformance.}
  54. \label{fig:example_A}
  55. \end{subfigure}
  56. \begin{subfigure}{0.4\textwidth}
  57. \centering
  58. \includegraphics[width=\columnwidth]{figures/example_solution.pdf}
  59. \caption{Using $\mathit{conformance}_\perp$.}
  60. \label{fig:example_B}
  61. \end{subfigure}
  62. \caption{Two different ontological views on the same model. The elements accessed by the algorithm are shown in light blue. Only $\mathit{conformance}_\perp$ complies with strict metamodelling.}
  63. \label{fig:example}
  64. \end{figure*}
  65. The complete procedure is shown in Figure~\ref{fig:overview}:
  66. first the $\mathit{conformance}_\perp$ view is taken on the model, where it is shown as a graph instead of a petri net model and metamodel.
  67. Second, this graph is traversed and the requested changes are performed.
  68. Finally, the modified graph model is again interpreted using the original conformance relation, where users use their own metamodel and corresponding type mapping to interpret the graph.
  69. \begin{figure}
  70. \includegraphics[width=\columnwidth]{figures/overview.pdf}
  71. \caption{Overview of the complete procedure: (1) reinterpret the model as instance of $\mathit{LTM}_\perp$, (2) execute the algorithm on the graph representation, (3) reinterpret the model again using the initial metamodel. All steps happen on the background and the user only sees the composite operation.}
  72. \label{fig:overview}
  73. \end{figure}