Possible for two seperate models interact?
Printed From: MetaCase
Category:
Forum Name: MetaEdit+
Forum Description: All topics relating to MetaEdit+ or DSM
URL: https://www.metacase.com/forums/forum_posts.asp?TID=62
Printed Date: 27.Mar.2026 at 03:35 Software Version: Web Wiz Forums 12.05 - http://www.webwizforums.com
Topic: Possible for two seperate models interact?
Posted By: vegaaa
Subject: Possible for two seperate models interact?
Date Posted: 25.Sep.2008 at 00:01
|
Hello MetaEdit!
First of all, thanks for a great DSL tool!
Second of all; When people start using programs like this with little(or no knowlage) at all, then many questions quickly raise!
So my first question for dev's are as follows;
I'm about to create a model A, and a model B. The model A is supposed to be code-dependant on the model B and similar they other way around.
Is there any way of doing this with your implementation of the tool as it is pr. now?
My second question is;
(Also about models interacting)
Can I visually - show relationship between models(the runtime models)?
I know from experience that dealing with the Visual Studi 08 SDK is really hard and complex concerning direct "connections" between models/diagrams.
Sorry for my rather bad english!
Thanks again for a great product!
Regards,
Vegard
|
Replies:
Posted By: stevek
Date Posted: 25.Sep.2008 at 13:47
|
Hi Vegard, and welcome to the forum!
With MetaEdit+, you can reuse and link information between two graphs in whatever way you want, even if the two graphs are of different types.
- If you copy and paste an object from one graph to another, you get two representations of the exact same object: if you change the name in one place, the new name shows up in all the other places that object is used. You can also break the link by creating a traditional copy with Paste Special, or then later with Replace.
- Individual properties too can be reused with "Share Property": e.g. if you have People objects you can have several different People, all with the same surname. Change the surname in one place, and the change is visible everywhere. You can later break the link with "Remove Sharing".
- If you have more complex properties than a simple string, they too can be reused. Rather than the value of a property being a string, it can be another object with its own set of properties.
- Objects, relationships and roles can have explosion links to other graphs, and each object can have a stronger decomposition link to a subgraph where it is described in more detail. You can even have more than one object having the same decomposition, e.g. two instances of the same component.
That's a short introduction to the common ways in which data can be shared, linked and reused in MetaEdit+. Above the conceptual data, you also have the visual representations. In the MetaEdit+ Symbol Editor you can define symbols that display data from not just that object, but also from further afield in the models. For instance, with a generator in a text field in a symbol, you can navigate to the subgraph of an object and show its name, or even the details of the objects in the subgraph.
Of course, all this power should be used for good, not evil :-). Having two models that are strongly interlinked in many ways is generally regarded as a Bad Thing, because it leads to high coupling and low cohesion. With a little thought, it's often possible to identify what the actual minimum information is that you need in your models, and avoid duplicating that information into two places either by typing the same string twice or copying objects many times. If all the information related to one thing is in one graph, it's a lot easier to work with and scales better than having it spread over two graphs.
In the generator, you can create multiple files from one graph, and output the same information into all the places in those files where it is needed. For an extreme example of the power and simplicity this gives, take a look at the S60 Phone C++ project. Generating code from the top-level graph there (which includes one subgraph) will create 27 different files, and strings that are written once in the models will be repeated in hundreds of places in those files. While the first thought on trying to create a modeling language for a system with 27 co-dependent files might be to have 27 co-dependent graphs, it's nice if we can insulate our modelers from that kind of baroque complexity!
|
Posted By: vegaaa
Date Posted: 01.Oct.2008 at 14:01
|
Hello and thanks for the reply.
I have another question as well;
is it even possible to map between models (A and B) that has different metamodels?
We want to create a connection between these models.
When this is acheived we'd also like to create a copy slighty different from the first model(A).
Our goal with this is ; We want to change an attribute(a=5) of an object C in model A by using model B which has connections to this object C with a new value(a=12).
Regards,
Vegard
PS: We know this is strange question, but for us this is very interesting.
|
Posted By: stevek
Date Posted: 01.Oct.2008 at 18:11
vegaaa wrote:
is it even possible to map between models (A and B) that has different metamodels?
|
Yes, that's what I meant when I said "you can reuse and link information between two graphs in whatever way you want, even if the two graphs are of different types."
vegaaa wrote:
Our goal with this is ; We want to change an attribute(a=5) of an object C in model A by using model B which has connections to this object C with a new value(a=12). |
This will work straightaway because you have the same object C in both models, so any changes to C in one model will affect the other (this corresponds to case 1. in my answer above). If what you have is actually C and C', a copy of C to depth 1 (using the terms from the Paste Special dialog), then there are two ways, depending on what "attribute a" means.
- If "attribute a=5" means C is a bit like a UML class, i.e. it has a property whose value is a list including an object O of type Attribute with properties name="a" and value="5", then this will work straightaway too: although C is different from C', the copy was only to depth 1, so C' will contain the same attributes as C, and hence any changes to O will be seen in both C and C'. (This corresponds to case 3. in my answer above.)
- If "attribute a=5" means C has a property called "a" which has a value 5, then if you want that property to be linked between C and C' you can use "Share Property" in that property field's pop-up menu. After that, any subsequent changes to the value of that property in C will result in the same change being visible in C'. (This corresponds to case 2. in my answer above.)
All this sounds complicated when explained in such painstaking detail on an abstract level. In practice in a concrete model it's all rather simple. For instance, open the "2008Models" graph in the Digital Watch example, open the X334 display, and edit the Button called "Mode" to change its name to "Next". When you OK the dialogs you'll see that the button's name changes in the other Displays too. If you open the "Simple" graph (which is a different metamodel), you can see that the button is called "Next" there too - and in all the other graphs where it is used.
|
Posted By: vegaaa
Date Posted: 02.Oct.2008 at 14:15
|
Sorry, the question was a bit unclear, our fault.
We have two different models(A and B) derived from two different metamodels(X and Y).
We want to use the model A(from metamodel X) in the environment of metamodel Y.
Model A has an object (Object C) with an attribute that has a given value(lets say a=5 as mentioned earlier).
We want to copy this Model A into the environment of the metamodel Y where we also have Model B. From there we'd like to use the Model B to express a new value for Object C, lets say a=12 without having any connection to Model A.
Then we want to use a self-written template to create a "copy" of Model A with the new changes made in Model B.
Our problem domain is described in a small figure(bad drawings, but you might get the figure:)) :
Thanks again for good and informative answers!
Regards,
Vegard and Christian.
PS: Sorry for my english.
|
Posted By: stevek
Date Posted: 02.Oct.2008 at 15:14
|
Hi Vegard and Christian,
First off: yes, you can do just what you suggest. You can make a copy of A with http://www.metacase.com/support/45/manuals/meplus/Mp-3_2_2.html#_Ref49763025 - Duplicate/Replace Graph . You can write a generator that will take one model of type X, e.g. A, and another of type Y, e.g. B, and create a new model of type X that is some combination of the two, e.g. A with a=12. If the combination is still 90% like A, I think I'd have the generator output A as an http://www.metacase.com/support/45/manuals/mwb/Mw-7_2.html - XML model file (.mxm), and then have it edit that either textually or with an XSLT generated based on model B, then import the resulting new .mxm file to get the new model A'. If the combination is more of a mixture, it might be easier to have the generator simply output the text of the desired .mxm file for new model A'.
I'm still wondering whether what you ask for is the best way to solve your problem with MetaEdit+. Whilst you may need to copy whole models (or their XML files) to achieve what you want in some DSM environments, because of their technical limitations, in MetaEdit+ you don't have those limitations, and so there may be better ways to achieve what you want. The main problem I see with what you have described is that you end up with three different model A's. Do you need all three? If you change something in one of them, do you want the same change in another?
Do the two "runtime" boxes in your picture mean you're thinking of having two different MetaEdit+ instances running? In some DSM environments, that might be the only way: you have to build one tool for metamodel X and a separate tool for metamodel Y. MetaEdit+ doesn't limit you like that: you can have as many metamodels as you like in the same running instance. You can also have multiple users all working on the same set of models and metamodels in a repository, with objects reused across several models (reuse by reference, not copy).
Does model B perhaps just describe a smallish set of changes to things in model A?
Do you need to have the final merged model A as a model that you want to edit, or would it be enough to be able to view it and to generate code etc. from it?
It would be easy enough to make MetaEdit+ show the original model A, but with the changes specified by B, so you could see a=12 -- all with just one model A. You'd just change a selection somewhere to choose whether to see the original A, or A modified by B (or any of a number of different instances of metamodel Y). In the same way, you could generate code that would integrate the information in A and B: generators in MetaEdit+ can pull information from as many models as you like, whatever their metamodels.
|
Posted By: vegaaa
Date Posted: 08.Oct.2008 at 19:18
|
Hello steve,
As far as we've understood, it is possible to reference different objects in different models derived from given metamodels in the same given repository. Is it possible to reference to different models that is not in the same repository? Or does all of the elements which you want to referr to need to be in the same working repository?
Yes, we've started on a soluion like you mention there. We've managed to change attributes of an object through another model(as described earlier). Then we traverse the base model and implement the new changes. This will eventually generate a new copy of the base model with all the implemented changes. (XML as MXM)
Some answers to your questions:
Q: Does model B perhaps just describe a smallish set of changes to things in model A?
A: Yes, the model B is supposed to describe some small changes to the elements in the model A.(Like changing an attribute A=3 to A=12).
Q: Do the two "runtime" boxes in your picture mean you're thinking of having two different MetaEdit+ instances running?
A: This was just a proposal to how we look at this problem as we are not sure about how this can be solved. We dont _need_ two instanes of MetaEdit to be running as long as we can reference to objects from model A in model B.
A solution to a similar problem is somewhat solved using the EMF/GMF (Eclipse) DLS tools. (Tho' this is not working 100% yet.)
Referencing an object or acutally whatever is quite simple in this context:
<img src=" http://static.nettby.no/users/v/y/g/vygy/files/BMReferences2.png - http://static.nettby.no/users/v/y/g/vygy/files/BMReferences2.png "/> (was not able to show the illustration here in the post[couldn't paste an image due to some problems with the posting editor  ])
Figure: Eclipse environment -> " get all modelelement in a project".
This image is illustrating a normal Eclipse environment. I've marked the most notable things her with a red circle.
The largest red circle(which is in the middle of the figure) illustrates all elements that exists in your project environment(Objects, Attributes, References and such).
All of this window's content is found by clicking on the button (...) (red circle to the right).
The element you choose from a base model(the window[largest circle]) will be stored in the context as "Base" (smallest circle to the left).
This "Base" attribute(/variable) helps us (on the transformation-level) to "remember" which object that had the attribute of e.g a=12 (as there could be several instances of a=12 in one diagram).
A last question:
Is there any similar way of referencing objects as we do in the eclipse environment(clicking on a <button> that gives us all elements thats in our models for a given project)?
That was alot of text right there!
Regards,
Vegard & Christian
PS: Sorry for the bad english. If something was unclear we'll try to reformulate ourselves.
|
Posted By: stevek
Date Posted: 09.Oct.2008 at 14:48
vegaaa wrote:
As far as we've understood, it is possible to reference different objects in different models derived from given metamodels in the same given repository. |
Yes, the referenced objects can be in different graphs, and even in different projects, providing they are in the same repository. If you want to refer to things not in the repository, you can use reference-by-name just like in source code or other modeling tools.
vegaaa wrote:
Is there any similar way of referencing objects as we do in the eclipse environment(clicking on a <button> that gives us all elements thats in our models for a given project)? |
Of course! In terms of the most similar UI, this would be a property whose value is an object. If you look in the Digital Watch example in the Stopwatch graph, each State there can specify a Display Function as a property. In this http://www.metacase.com/blogs/stevek/images/AttachExistingDisplayFn.html%20 - screencast , you can see how the "Running" State's property dialog is opened and the existing "elapsedTime" is attached as the value of its DisplayFn property. This used the "Component Selection Tool" (the dialog with "Select a DisplayFn"). To show another way, we press Undo to get back to the initial situation where Running has no DisplayFn. We then select "elapsedTime" and Copy it, then edit "Running" and Paste "elapsedTime" as its DisplayFn property. To prove this is a real reference, not just a string copy, we change the name of the DisplayFn in the graph to "elapsed" and can see the same change in the "Running" State.
In this case, the object to refer to was in the same graph. You can of course use either method to fetch objects from further away. In the Component Selection Tool, you can press the Graphs button to show a list of all graphs, choose one to see its objects, navigate from that object into a subobject or sub-graph etc. Since those paths could sometimes be several steps, the most recent paths are saved in the Selection History list at the top of the dialog, so you can quickly jump back to the last places from where you selected objects.
As I said, that is the most similar way. It would also be possible to copy and paste objects from model A into model B, and then link them to change objects by relationships. For instance, you could paste the whole object as a big symbol, then within that paste smaller symbols for the attributes that you want to change, linking each of those smaller symbols to its own object specifying the new value. The "big symbols" and "smaller symbols" would both be direct references to the objects and attributes of model A; the objects specifying values would be new objects in B.
|
Posted By: chrisrud
Date Posted: 10.Oct.2008 at 12:18
|
Hello Thank you for very nice demonstration. Our next step is a little bit trickier. What we actually want to do is to just like that, but only with a slightly difference. Your demo shows how to refer objects in another project if you know their type. Is it possible to do the same if you do not know the type? In that case we could make a general solution that could have references to objects whether it is in one project or another. (we do not want to define the actual object type which we will refer to) maybe there is a object type that defines every objects made in metaEdit? Regards Vegard and Christian
|
Posted By: stevek
Date Posted: 10.Oct.2008 at 13:20
|
What you can link to is defined in the metamodel. Normally of course it is important that you can only link to a certain type of object. For instance, the DisplayFn in the previous example tells the State how to calculate the time to display on the watch; if we put a Button rather than a DisplayFn in the State, it's rather unlikely that the button is going to give a good answer. We've thus defined that the DisplayFn property used in State is of datatype "DisplayFn object".
If you want to allow more than one kind of object, you can use inheritance: just make the property datatype be the supertype. The Digital Watch has an example of inheritance in how the relationships work: the lines from the green DisplayFn objects are defined in the metamodel as being able to connect to the black objects of type Variable, like startTime. As you can see from the screencast, some also connect to the gray objects of type VariableRef, like sysTime. This works because VariableRef is a subtype of Variable.
If you want to allow a link to any of your object types, you can make one supertype at the top of your whole type hierarchy, and refer to that. If you really want to allow linking to absolutely any object type, even ones that are in different modeling languages that you haven't defined, you can link to Object, which is the supertype of all object types. Normally you won't see Object in the lists of types that you can select from in the metamodeling tools. To see it in those menus or dialogs, hold down shift when you open them (e.g. when selecting Object... in the Datatype menu in the Property tool).
|
Posted By: chrisrud
Date Posted: 10.Oct.2008 at 13:38
|
That's great, this is what we wanted. Thank you very much! regards Vegard and Christian
|
Posted By: chrisrud
Date Posted: 10.Oct.2008 at 14:19
|
Hi again, not cruical, but interesting: Is it possible to refer an object that is not in the same repository and derived from a different dsl, without knowing its type? regards
Vegard and Christian
|
Posted By: stevek
Date Posted: 10.Oct.2008 at 14:31
|
As I said above, you can't refer directly to an object in a different repository. Or rather, all the wonderful things MetaEdit+ can do for direct references in the same repository can't help you in making links to a different repository. You can't really update the name in one place and hope that it will be updated automatically in some other random repository :-).
Since we're all used to this from source code, it's hardly a new problem. You just have to make sure you copy&paste or type the same name. Given that MetaEdit+ can solve that problem for 99% of your links, it's hopefully OK if for the last 1% you still need to do it in the old familiar way.
If the figure is significantly greater than 1%, you may want to revisit your design and aim for better cohesion and lower coupling. Think what happens when you have multiple people working on multiple models in multiple repositories, with multiple versions of each repository. In that situation, UML-like solutions are terrible or require draconian rules, DSM solutions work just fine: a large part of the difference is in having direct references and good modularization.
|
Posted By: jpt
Date Posted: 10.Oct.2008 at 15:12
|
Hi,
I don’t know your requirements for the language support and its use case, but I would define an integrated metamodel rather than try to develop a solution consisting of multiple disconnected models that need to be updated and kept connected with extra effort.
In database world we define a schema to store the data and keep it updated and consistent. This is opposite to having multiple different kind of files that then refer to each other via some mechanisms for creation, update and deletion of their individual items. By defining a metamodel that allows to integrate design data based on different languages makes modeling work . I would also argue that the actual language definition becames then easier for you too.
Yours,
Juha-Pekka
|
|