|
|
(16 intermediate revisions by 4 users not shown) |
Line 1: |
Line 1: |
| | |
| <html> | | <html> |
| <html> | | <h4> |
| <style>
| | An introduction to OCL - the Object Constraint Language - through examples. This session also introduces the new MDriven Debugger |
| #video12 {
| | and shows how to get instant results from modeling efforts. |
| position: relative;
| | </h4> |
| height: 500px;
| |
| width:560px;
| |
| padding-bottom: 10px;
| |
| }
| |
| #video12 iframe {
| |
| position: absolute;
| |
| min-height: auto; | |
| min-width: auto;
| |
| }
| |
| #video12 div {
| |
| position: absolute;
| |
| top: 0;
| |
| left:760px;
| |
| width: 260px;
| |
| height: 100%;
| |
| padding-left: 10px;
| |
| overflow-y: auto;
| |
| }
| |
| span {
| |
| font-size: 18;
| |
| display:block;
| |
| padding: 2px 10px 2px 10px;
| |
| padding-bottom: 0.5;
| |
| padding-top: 0.5;
| |
| opacity: 0.7;
| |
| }
| |
| span:hover {
| |
| color: #0000FF;
| |
| cursor: pointer;
| |
| }
| |
| span:focus {
| |
| color: blue;
| |
| </style>
| |
| | |
| <h5>
| |
| An introduction to OCL - the object contraints language - by example. | |
| The session also introduce the new MDriven debugger and shows how to get instant results of modelling efforts.
| |
| </h5> | |
|
| |
|
| <p> | | <p class="warn"> |
| <em>To make your experience more comfortable, we set the main tags mentioned in the video to the right bar menu of this mini player. Choose the interesting subtitle on the list and immediately get to the exact theme timeplace in the video. Now you can pick any topic to be instructed without watching the whole video.</em> | | <em>To make your experience smooth, we set the main tags mentioned in the video to the right bar menu of this mini-player. Choose an interesting subtitle on the list and immediately get to the exact theme navigation item place in the |
| <style type="text/css">
| | video. Now you can pick any topic to be instructed on without watching the whole video.</em> |
| p {
| |
| opacity: 0.7;
| |
| text-align: justify;
| |
| width: 90%
| |
| }
| |
| </style>
| |
| </p> | | </p> |
|
| |
|
| <div id="video12"> | | <br> |
| <iframe width="740" height="500" src="https://www.youtube.com/embed/DBEP3oMWsIg?rel=0&autoplay=0" frameborder="0" allowfullscreen></iframe>
| | <div class="video"> |
| <div> | | <div class="video__wrapper"> |
| <strong>Common expressions</strong> | | <iframe src="https://www.youtube.com/embed/YwNDD-jlkWw?rel=0&autoplay=0" frameborder="0" allowfullscreen></iframe> |
| <ul>
| | </div> |
| <span data-video="DBEP3oMWsIg" data-start="54" tabindex="0">.create </span> | | <div class="video__navigation"> |
| <span data-video="DBEP3oMWsIg" data-start="77" tabindex="0">.allinstances</span> | | <strong> Common expressions</strong> |
| <span data-video="DBEP3oMWsIg" data-start="275" tabindex="0">.select</span> | | <span class="navigation-item" data-video="YwNDD-jlkWw" data-start="59" tabindex="0">.create </span> |
| <span data-video="DBEP3oMWsIg" data-start="618" tabindex="0">.asstring</span> | | <span class="navigation-item" data-video="YwNDD-jlkWw" data-start="82" tabindex="0">.allinstances</span> |
| <span data-video="DBEP3oMWsIg" data-start="1145" tabindex="0">.representation</span> | | <span class="navigation-item" data-video="YwNDD-jlkWw" data-start="280" tabindex="0">.select</span> |
| </ul>
| | <span class="navigation-item" data-video="YwNDD-jlkWw" data-start="623" tabindex="0">.asstring</span> |
| <span data-video="DBEP3oMWsIg" data-start="104" tabindex="0">at0 and at operator</span> | | <span class="navigation-item" data-video="YwNDD-jlkWw" data-start="1150" tabindex="0">.representation</span> |
| <span data-video="DBEP3oMWsIg" data-start="127" tabindex="0">assign operator</span> | | <span class="navigation-item" data-video="YwNDD-jlkWw" data-start="109" tabindex="0">at0 and at operator</span> |
| <span data-video="DBEP3oMWsIg" data-start="110" tabindex="0">orderby</span> | | <span class="navigation-item" data-video="YwNDD-jlkWw" data-start="132" tabindex="0">assign operator</span> |
| <span data-video="DBEP3oMWsIg" data-start="183" tabindex="0">orderbyDescending</span> | | <span class="navigation-item" data-video="YwNDD-jlkWw" data-start="115" tabindex="0">orderby</span> |
| <span data-video="DBEP3oMWsIg" data-start="192" tabindex="0">loopvar</span> | | <span class="navigation-item" data-video="YwNDD-jlkWw" data-start="188" tabindex="0">orderbyDescending</span> |
| <span data-video="DBEP3oMWsIg" data-start="260" tabindex="0">ocl editor overhaul support</span> | | <span class="navigation-item" data-video="YwNDD-jlkWw" data-start="197" tabindex="0">loopvar</span> |
| <span data-video="DBEP3oMWsIg" data-start="352" tabindex="0">execution of expressions</span> | | <span class="navigation-item" data-video="YwNDD-jlkWw" data-start="265" tabindex="0">ocl editor overhaul support</span> |
| <span data-video="DBEP3oMWsIg" data-start="488" tabindex="0">union operator</span> | | <span class="navigation-item" data-video="YwNDD-jlkWw" data-start="357" tabindex="0">execution of expressions</span> |
| <span data-video="DBEP3oMWsIg" data-start="531" tabindex="0"> ocl use in the model (string representation)</span> | | <span class="navigation-item" data-video="YwNDD-jlkWw" data-start="483" tabindex="0">union operator</span> |
| <span data-video="DBEP3oMWsIg" data-start="630" tabindex="0"> collect operator </span> | | <span class="navigation-item" data-video="YwNDD-jlkWw" data-start="536" tabindex="0"> ocl use in the model (string representation)</span> |
| <span data-video="DBEP3oMWsIg" data-start="678" tabindex="0"> member of ECOModel Root </span> | | <span class="navigation-item" data-video="YwNDD-jlkWw" data-start="635" tabindex="0"> collect operator </span> |
| <span data-video="DBEP3oMWsIg" data-start="699" tabindex="0"> abstract classes and its inheritance </span> | | <span class="navigation-item" data-video="YwNDD-jlkWw" data-start="683" tabindex="0"> member of ECOModel Root </span> |
| <span data-video="DBEP3oMWsIg" data-start="912" tabindex="0"> specialization .OclType </span> | | <span class="navigation-item" data-video="YwNDD-jlkWw" data-start="704" tabindex="0"> abstract classes and its inheritance </span> |
| <span data-video="DBEP3oMWsIg" data-start="1116" tabindex="0"> derived attribute </span> | | <span class="navigation-item" data-video="YwNDD-jlkWw" data-start="917" tabindex="0"> specialization .OclType </span> |
| </div> | | <span class="navigation-item" data-video="YwNDD-jlkWw" data-start="1121" tabindex="0"> derived attribute </span> |
| | </div> |
| </div> | | </div> |
|
| |
|
|
| |
| <script>
| |
| var IMG = document.querySelectorAll('#video12 span'),
| |
| IFRAME = document.querySelector('#video12 iframe');
| |
| for (var i = 0; i < IMG.length; i++) {
| |
| IMG[i].onclick = function() {
| |
| IFRAME.src = 'http://www.youtube.com/embed/' + this.dataset.video + '?rel=0&autoplay=1';
| |
| if(this.dataset.end) IFRAME.src = IFRAME.src.replace(/([\s\S]*)/g, '$1&end=' + this.dataset.end);
| |
| if(this.dataset.start) IFRAME.src = IFRAME.src.replace(/([\s\S]*)/g, '$1&start=' + this.dataset.start);
| |
| this.style.backgroundColor='rgba(0,0,0,.2)';
| |
| }
| |
| }
| |
| </script>
| |
| </html> | | </html> |
|
| |
|
| Raw subtitles text
| | [[Category:MDriven Designer]] |
| | | [[Category:OCL]] |
| hi and welcome to the session on ocl
| | [[Category:OCL Editor]] |
| | | [[Category:Expressions]] |
| expressions start with a simple model
| | [[Category:Derivations]] |
| | | [[Category:Operators]] |
| containing of fruits orange as one
| | {{Edited|July|12|2024}} |
| | |
| property
| |
| | |
| weight type integer and gonna start a
| |
| | |
| system running this saving data to an xml file
| |
| | |
| that we save on in temp file "fruit"
| |
| | |
| I'm going to use the new debugger
| |
| | |
| so if you haven't seen this before
| |
| | |
| it's a good introduction to that as well
| |
| | |
| and the new debugger allows you to
| |
| | |
| write actions as long as ocl, so we
| |
| | |
| could do orange.create and then
| |
| | |
| we have actually created one orange object
| |
| | |
| an instance of the class, so let's
| |
| | |
| create some oranges and once we have them we
| |
| | |
| can do orange.all instances
| |
| | |
| which is a common ocl operator to show all
| |
| | |
| instances of a certain class
| |
| | |
| as we see the weight is 0. It's the default value for
| |
| | |
| integer that's not nullable
| |
| | |
| and we can index the list of all instances with
| |
| | |
| the "at(0) operator
| |
| | |
| so at 0 there's also an at operator, but at(0) is
| |
| | |
| zero based the at operator is one based
| |
| | |
| so starting from zero to count minus 1
| |
| | |
| or length minus one
| |
| | |
| and let's do an action at first object at list
| |
| | |
| assigning the weight to 18
| |
| | |
| so this is the assign operator colon equals and
| |
| | |
| we can set the weight values
| |
| | |
| something like that and then we'd save,
| |
| | |
| now we have saved them to the xml file
| |
| | |
| that we stated initially and in ocl we can
| |
| | |
| do a lot of different operations
| |
| | |
| let's check out the "orderby", orderby(weight)
| |
| | |
| and there's also an orderby this ending
| |
| | |
| and in all these iterations, there
| |
| | |
| can be a loop variable and
| |
| | |
| it's separated with the pipe sign, so that's
| |
| | |
| what you here, the loopvar
| |
| | |
| it is just each object iterating
| |
| | |
| in the loop, so it will be of the type
| |
| | |
| that interested iteration, so orderDescending,
| |
| | |
| or orderby
| |
| | |
| results an operation for first and of
| |
| | |
| course one for last that the given a list
| |
| | |
| just returns one object and you can
| |
| | |
| combine ocl expressions
| |
| | |
| so order descending last
| |
| | |
| the ocl editor has been given an
| |
| | |
| overhaul to better support
| |
| | |
| support you as you type your expressions it's
| |
| | |
| not perfect and we will see some issues with it
| |
| | |
| but it's getting there
| |
| | |
| select is a common ocl operator
| |
| | |
| that we want to limit our results at
| |
| | |
| here we select on the weight larger than 20,
| |
| | |
| but the loop variable is optional,
| |
| | |
| so you do not always need it
| |
| | |
| all kind of comparison operators are
| |
| | |
| available larger than or equal etc.
| |
| | |
| let's add another class, apple
| |
| | |
| also has a weight
| |
| | |
| and if I do apple.all instances apple is
| |
| | |
| not a type name, because I need to
| |
| | |
| reread the model in order to have my
| |
| | |
| executor to know about it
| |
| | |
| so once I re-read and it doesn't give me
| |
| | |
| the error, but there are no apples of course
| |
| | |
| so write action: and then Apple.create
| |
| | |
| get two of those, five and the new debugger
| |
| | |
| here interprets all continuous lines
| |
| | |
| as one expression, so you need to
| |
| | |
| leave an empty roll between
| |
| | |
| expressions that are not supposed to
| |
| | |
| belong to each others
| |
| | |
| and of course it defaults to ocl but as soon as you
| |
| | |
| write action: it will do action language instead
| |
| | |
| which allows you to set values to operate on values to change state
| |
| | |
| normally ocl is totally free from side effects
| |
| | |
| but the action language that is unique for MDriven
| |
| | |
| allows you to operate objects as well
| |
| | |
| with the ocl syntax so we're
| |
| | |
| setting some weights on the apples
| |
| | |
| and we saved that state
| |
| | |
| so Apple.all instances also have the
| |
| | |
| oranges since before
| |
| | |
| these are the oranges
| |
| | |
| these are the apples and what we can do
| |
| | |
| is combine them, the operator called "union"
| |
| | |
| so there we are together, but we don't
| |
| | |
| see not very clear what they are
| |
| | |
| so let's add the default string
| |
| | |
| representation to the classes
| |
| | |
| this is one place where you actually use ocl
| |
| | |
| in the model of course you use it all
| |
| | |
| over the model but this is just one of
| |
| | |
| the places "orange with weight of
| |
| | |
| and then we grab our "selves" weight and append
| |
| | |
| grams, but since weight is an integer
| |
| | |
| we need to convert it to as #sString in
| |
| | |
| order to get use a +operator on strings
| |
| | |
| let's do the same thing for the Apple
| |
| | |
| but right Apple instead save the model
| |
| | |
| yes still don't see anything because we
| |
| | |
| haven't said that we want
| |
| | |
| to see it as string, the default string
| |
| | |
| representation on the obvious now I see them
| |
| | |
| what I can do is use to collect
| |
| | |
| operator, to build a tuple of pieces from
| |
| | |
| the result that I'm working on
| |
| | |
| so the loop variable will be one of the
| |
| | |
| objects in the iteration and that should
| |
| | |
| have weight and I can do that as string
| |
| | |
| if I can spell, but now we see that weigh it,
| |
| | |
| this is not correct weight is not a
| |
| | |
| member of eco model root
| |
| | |
| why does it say EcoModelRoot well
| |
| | |
| because that's the common denominator
| |
| | |
| between apple and orange currently,
| |
| | |
| so here we have discovered a need for an
| |
| | |
| abstraction really apple and orange are
| |
| | |
| really sharing things
| |
| | |
| we should make that available in the model
| |
| | |
| so that we can operate on it
| |
| | |
| so let's interview the abstraction
| |
| | |
| called fruit and we model this with the
| |
| | |
| generalization arrow
| |
| | |
| and we want to add the attribute
| |
| | |
| weight to fruit, but doing so we will find that there's error
| |
| | |
| reported on model,
| |
| | |
| because now orange and apple inherit weight from fruit and they
| |
| | |
| have fruit on their own so that's not allowed
| |
| | |
| but renaming it to new weight instead of weight,
| |
| | |
| so we can see that we get it work
| |
| | |
| new weight, then it's ok but of course
| |
| | |
| the new wa is 0, because we haven't set
| |
| | |
| but now we can do act on the
| |
| | |
| abstraction the fruit fruit.allinstansec
| |
| | |
| as string, that will return both
| |
| | |
| oranges and apples,
| |
| | |
| but it reports common denominator as new weight is the
| |
| | |
| only thing they share
| |
| | |
| so let's say that this is the weight and
| |
| | |
| there is actually no need for a unique
| |
| | |
| weight to apples or unique weight on oranges
| |
| | |
| it's just weight of the fruit
| |
| | |
| then we see the weight on the fruit
| |
| | |
| so this is why modeling is so good
| |
| | |
| because it works exactly as we think
| |
| | |
| about things in daily life, we use
| |
| | |
| abstractions all the time just getting
| |
| | |
| around life, just grabbing a chair on our
| |
| | |
| new office that we've never visited before
| |
| | |
| him instantly knowing that it
| |
| | |
| will work as any other chair is our ability to abstract
| |
| | |
| but having the fruits can we access
| |
| | |
| their specialization what they're
| |
| | |
| actually called what kind of fruit they are
| |
| | |
| yes, there's some ocl-type operator with
| |
| | |
| the type name that gives us this information
| |
| | |
| orange and apple, there we see, so that would
| |
| | |
| allow us to break out the hard-coded orange
| |
| | |
| to self ocl-type typename
| |
| | |
| remove the orange and of course if we do
| |
| | |
| it there we might as well
| |
| | |
| yeah let's, look at this first
| |
| | |
| orange.string is still ok, so if we can
| |
| | |
| do that we might as well move it up to fruit
| |
| | |
| going to remove it from the
| |
| | |
| subclasses just have it on the
| |
| | |
| superclass fruit, so like that, re-read
| |
| | |
| yay works like before but with less code or less ocl
| |
| | |
| the fruit is actually abstract we don't think of fruit as being
| |
| | |
| there's no, nothing existing just
| |
| | |
| being fruit is either orange or Apple in our model
| |
| | |
| so I mark it as abstract and
| |
| | |
| the class name is drawn italic instead
| |
| | |
| I can create apples, but I'm not supposed
| |
| | |
| to be able to create fruit
| |
| | |
| can't instantiate abstract class fruit, this
| |
| | |
| will help us to avoid doing illegal
| |
| | |
| things as our model evolves, orange I can
| |
| | |
| create oranges and apples but not fruits
| |
| | |
| that's ok and I can access fruit all instances or
| |
| | |
| just the oranges or just the apples
| |
| | |
| and I can act on fruits checking their
| |
| | |
| weight and I get us all the fruits
| |
| | |
| having a weight larger than 20 grams both oranges
| |
| | |
| and apples and move this or rather copy it
| |
| | |
| to a new attribute, attributes
| |
| | |
| this attribute is called presentation
| |
| | |
| not going to make it derived, derived
| |
| | |
| attribute can be backed by an derivation ocl
| |
| | |
| and ocl expression this is another
| |
| | |
| place where you commonly use ocl going
| |
| | |
| to set the same thing as in the default
| |
| | |
| string representation, but since I
| |
| | |
| defined it as a derived attribute might
| |
| | |
| as well use it in the default string representation
| |
| | |
| reduce the definitions,
| |
| | |
| re-read the model, since we changed it and
| |
| | |
| now when I execute I see I have a new
| |
| | |
| property on the object fruit called presentation
| |
| | |
| that works for apples and the first
| |
| | |
| Apple is Apple would wait 15 grams
| |
| | |
| let's see, if I can change its weight
| |
| | |
| and watch when I change the weight both
| |
| | |
| the derived presentation and the weight changes
| |
| | |
| this is an extremely large and
| |
| | |
| positive thing with derived attributes
| |
| | |
| they subscribe to every change that you
| |
| | |
| see in the model reduces the amount of
| |
| | |
| code you need to write or the amount of
| |
| | |
| ocl, so that was the first part of the ocl
| |
| | |
| I'm going to come back straight away
| |
| | |
| with another part continuing with
| |
| | |
| the same sample thank you for watching, so far
| |