MetaCase Homepage
Forum Home Forum Home > > MetaEdit+
  New Posts New Posts RSS Feed - Possible for two seperate models interact?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Possible for two seperate models interact?

 Post Reply Post Reply Page  12>
Author
Message
vegaaa View Drop Down
Member
Member
Avatar

Joined: 24.Sep.2008
Location: Norway
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote vegaaa Quote  Post ReplyReply Direct Link To This Post Topic: Possible for two seperate models interact?
    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


Edited by vegaaa - 10.Oct.2008 at 16:53
Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 643
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevek Quote  Post ReplyReply Direct Link To This Post 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.
  1. 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.
  2. 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".
  3. 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.
  4. 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!


Edited by stevek - 01.Oct.2008 at 17:50
Back to Top
vegaaa View Drop Down
Member
Member
Avatar

Joined: 24.Sep.2008
Location: Norway
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote vegaaa Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 643
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevek Quote  Post ReplyReply Direct Link To This Post Posted: 01.Oct.2008 at 18:11
Originally posted by vegaaa 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."
 
Originally posted by vegaaa 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.
  1. 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.)
  2. 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.

Back to Top
vegaaa View Drop Down
Member
Member
Avatar

Joined: 24.Sep.2008
Location: Norway
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote vegaaa Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 643
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevek Quote  Post ReplyReply Direct Link To This Post 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 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 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.
Back to Top
vegaaa View Drop Down
Member
Member
Avatar

Joined: 24.Sep.2008
Location: Norway
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote vegaaa Quote  Post ReplyReply Direct Link To This Post 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"/>
(was not able to show the illustration here in the post[couldn't paste an image due to some problems with the posting editorStar])
 
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.


Edited by vegaaa - 09.Oct.2008 at 13:43
Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 643
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevek Quote  Post ReplyReply Direct Link To This Post Posted: 09.Oct.2008 at 14:48
Originally posted by vegaaa 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.
 
Originally posted by vegaaa 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 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.


Edited by stevek - 09.Oct.2008 at 15:03
Back to Top
chrisrud View Drop Down
Member
Member
Avatar

Joined: 09.Oct.2008
Location: Norway
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote chrisrud Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 643
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevek Quote  Post ReplyReply Direct Link To This Post 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).
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.05
Copyright ©2001-2022 Web Wiz Ltd.

This page was generated in 0.045 seconds.