Part 2 OCL: Operators
No edit summary
(Automatically adding template at the end of the page.)
 
(19 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<html>
<html>
<style>
#video12 {
  position: relative;
  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>
<h4>
An introduction to OCL - the object constraints language - by example. The session also introduce the new MDriven debugger and shows how to get instant results of modelling efforts.
  An introduction to OCL - the Object Constraint Language - through an example. This session introduces the new MDriven Debugger
This particular session explains the configuration of different operator, concept of derivation and principles of various ocl associaton tools by practical example . It's as closely clear and understanble to learn and to be taught with.
  and shows how to get instant results from modeling efforts. This particular session explains the configuration of different
  operators, the concept of derivation, and the principles of various OCL association tools through a practical example. It is as clear
  and understandable as possible to learn or be taught with.  
</h4>


</h5>
<p class="warn">
 
  <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 video. Now you can pick any topic to be instructed on without watching the whole video.</em>
<p>
<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>
<style type="text/css">
p {
opacity: 0.7;
text-align: justify;
width: 90%
}
</style>
</p>
</p>


<div id="video12">
<div class="video">
<iframe width="740" height="500" src="https://www.youtube.com/embed/GCrqRJ_gzx0?rel=0&autoplay=0" frameborder="0" allowfullscreen></iframe>
  <div class="video__wrapper">
   <div>
    <iframe src="https://www.youtube.com/embed/37nQRqQvLqM?rel=0&autoplay=0" frameborder="0" allowfullscreen>
 
      </iframe>
     <strong> This part includes overview on:</strong>
   </div>
    <ul>
  <div class="video__navigation">
     <span data-video="GCrqRJ_gzx0" data-start="23" tabindex="0"> code comments </span>
     <strong> This part includes an overview on:</strong>
     <span data-video="GCrqRJ_gzx0" data-start="62" tabindex="0"> associations </span>
     <span class="navigation-item"  data-video="37nQRqQvLqM" data-start="23" tabindex="0"> code comments </span>
     <span data-video="GCrqRJ_gzx0" data-start="137" tabindex="0"> temporary variables introduction (temp operator)</span>
     <span class="navigation-item"  data-video="37nQRqQvLqM" data-start="62" tabindex="0"> associations </span>
     <span data-video="GCrqRJ_gzx0" data-start="222" tabindex="0"> add operator </span>
     <span class="navigation-item"  data-video="37nQRqQvLqM" data-start="137" tabindex="0"> temporary variables introduction (temp operator)</span>
     <span data-video="GCrqRJ_gzx0" data-start="248" tabindex="0"> at(0) operator</span>
     <span class="navigation-item"  data-video="37nQRqQvLqM" data-start="222" tabindex="0"> add operator </span>
   
     <span class="navigation-item"  data-video="37nQRqQvLqM" data-start="248" tabindex="0"> at(0) operator</span>
     <span data-video="GCrqRJ_gzx0" data-start="303" tabindex="0"> derivation </span>
     <span class="navigation-item"  data-video="37nQRqQvLqM" data-start="303" tabindex="0"> derivation </span>
     <span data-video="GCrqRJ_gzx0" data-start="338" tabindex="0"> asCommaList operator </span>
     <span class="navigation-item"  data-video="37nQRqQvLqM"   data-start="338" tabindex="0"> asCommaList operator </span>
     <span data-video="GCrqRJ_gzx0" data-start="382" tabindex="0"> if operator </span>
     <span class="navigation-item"  data-video="37nQRqQvLqM" data-start="382" tabindex="0"> if operator </span>
     <span data-video="GCrqRJ_gzx0" data-start="508" tabindex="0"> groupby operator</span>
     <span class="navigation-item"  data-video="37nQRqQvLqM"   data-start="508" tabindex="0"> groupby operator</span>
     <span data-video="GCrqRJ_gzx0" data-start="720" tabindex="0"> sum operator </span>
     <span class="navigation-item"  data-video="37nQRqQvLqM" data-start="720" tabindex="0"> sum operator </span>
     <span data-video="GCrqRJ_gzx0" data-start="770" tabindex="0">add criteria to the grouping </span>
     <span class="navigation-item"  data-video="37nQRqQvLqM"   data-start="770" tabindex="0">add criteria to the grouping </span>
     <span data-video="GCrqRJ_gzx0" data-start="947" tabindex="0"> adding a variables </span>
     <span class="navigation-item"  data-video="37nQRqQvLqM"   data-start="947" tabindex="0"> adding variables </span>
     <span data-video="GCrqRJ_gzx0" data-start="977" tabindex="0">m1, m2, m3 collections </span>  
     <span class="navigation-item"  data-video="37nQRqQvLqM" data-start="977" tabindex="0">m1, m2, m3 collections </span>
     <strong> Collection operators </strong>
     <strong> Collection operators </strong>
      <ul>
    <span class="navigation-item"  data-video="37nQRqQvLqM" data-start="1149" tabindex="0" intersection <span>symmetric difference operator </span>
        <span data-video="GCrqRJ_gzx0" data-start="1149" tabindex="0" intersection <span>symmetric difference operator </span>  
    <span class="navigation-item"  data-video="37nQRqQvLqM" data-start="1219" tabindex="0">difference operator </span>
        <span data-video="GCrqRJ_gzx0" data-start="1219" tabindex="0">difference operator </span>  
  </div>
      </ul>
</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>
 
[[Category:OCL]]
'''Raw subtitles text'''
[[Category:OCL Editor]]
 
[[Category:Expressions]]
I welcome back this is session two of
[[Category:Operators]]
 
{{Edited|July|12|2024}}
the ocl expressions extending the model
 
with a fruit bowl, given it a property
 
name and then this is also new that you
 
when you enter code comments on
 
classes, you will have access to them
 
in the ocl editor, so this will help you
 
as your model grows to know what is what
 
so in the ocl editor, whenever you edit something and you point at it
 
it says the code comments, so that's a new thing
 
ok and the fruit bowl, it's supposed to contain fruit
 
toggle square line to ensure that
 
Association line is always squared
 
going to give the association ends better names
 
than the defaults and this is the multiplicity and
 
it's 0 to many and in the other end
 
it's 0 to 1, so the fruit can be in one bowl and bowl
 
can contain many fruits, that's either in orange or an apple
 
so re-reading the model
 
create a bowl and this is a way to, in ocl,
 
to introduce temporary variables
 
let's make it easier for you to set
 
multiple properties just showing you for
 
this is the purpose of this video so
 
let the let operator temp is a temporary variable from both create in
 
and then you can use the temporiable
 
you can set the property, so this is one
 
expression that creates and sets the
 
property in one goal
 
going to create another one plastic bowl
 
one glass bowl and one plastic bowl
 
there we have them, first I'm going to work on the glass
 
bowl, it's a collection of fruit bowl, but I
 
just one to one, so I say first.FruitinBowl
 
that's the collection of fruit I want to
 
add fruit, add operator
 
so now I need to find a fruit
 
fruit.all instances, but that's a collection of fruit
 
I need one fruit to add I used to at(0)
 
operator again, grabing a zero fruit
 
the first fruit and then I change
 
this to add another fruit
 
and then I would be able to see rather
 
in the glass bowl the fruit in bold
 
I see I have three fruits, two oranges and
 
one apple, ok and let's add an attribute that states
 
what it contains, contains this fruit to
 
make that derived and the derivation
 
should be fruit in bowl presentation but
 
that will be a collection of string, we
 
need a single string and there's an
 
operator asCommaList simply takes a list
 
of strings and sets a comma between each
 
re-read the model like that "contains this fruit"
 
that's the glass bowl, but ocl also has an "if" operator, so
 
let's see if the fruit in bowl is empty
 
then we return the string "no fruit at all"
 
else wereturn the one we just constructed
 
and if ,it's important to end your
 
expression, and both parts of the
 
expression must return the same type in
 
this case a string, so if we look at all
 
the fruit bowls, we can spell all
 
instances correct,  we see that the glass bowl
 
has fruits and the plastic bowl has
 
no fruit at all, but if I were to add
 
fruit to the glass bowl, the derived
 
property would get another apple in this
 
case undo that, we do under so fully
 
subscribe and what if we were to add one to the plastic bowl
 
now we'll see a important principle that
 
our model states that the fruit can only
 
be in one bowl at a time, so
 
adding it to get up on the bowl to the
 
plastic bowl, actually removes it from
 
the glass bowl, this is of course obvious
 
but not so obvious when programming
 
against databases etc
 
modeling really helps us to work in high level of
 
abstraction to do things right
 
just to say supposed to be straightaway
 
avoiding a lot of simple mistakes w
 
we have a groupby operator in ocl, that we
 
can use to certain things
 
let's see how it works, if you have a
 
collection of something you can collect
 
over it and state what you want to group
 
by what's the unique property that you
 
want to isolate and keep and sort,
 
to group the other items by, so I want to
 
order by the type, ocl typename, but wait
 
a minute this wasn't what I expected
 
it's a string, I wrote the wrong thing I
 
wrote the property contains this fruit
 
when I intended to write the association fruit in bowl
 
so now I have first, part one that will
 
contain the type name and then a list a
 
list of the ones that are of the type, so
 
then we can continue and use to result
 
can collect and get the presentation of each fruit in the list,
 
yeah since the list contains many it
 
will be a collection of
 
no, actually, that the list needs to have...
 
it needs to, its case sensitive
 
the property was named list with the big L
 
you need to get that, like this,
 
asCommaList to reduce the collection of
 
strings, to a simple string, ok so
 
and now we have grouped the fruits in
 
the bowl and oranges on one end and a
 
apples on the other end and when we
 
remove or move the fruit we will see the effect
 
and let's copy that and do and yet
 
another tuple part, summing up the weights
 
there is an ocl operator sum
 
that just adds up all the numbers and
 
let's elaborate a bit on what to write
 
so the orange weight sums up to 43 grams
 
the apple weight sums up to 21 grams
 
but the groupby only chcks on type
 
name, what we can do is also add another
 
criteria to the grouping and that would
 
be what bowl the fruit is in
 
like that, so now we know what bowl
 
the fruit is in and we could use that
 
information in our text presentation
 
the tool tuple +x and there's a new part
 
of the tuple, but wait a minute
 
it's not called part2 since this is a
 
strict model name InBowl, we can use that
 
when we create a tuple, so that's
 
used, so this expression it's rather harry
 
but then if we remove the criteria
 
to only check the glass bowl we will see
 
that the use of it, now we sum up and see
 
that the plastic bowl has the weight of 23 grams
 
let's set another derived
 
attribute on the fruit bowl
 
summing up the the weight of the
 
contents, derived, derivation ocl
 
should grab the fruit in the
 
bowl, the weight and the operator sum
 
so re-reading the model
 
we see the weight of the contents and we
 
see contains this fruit, etc
 
if we add a move fruit the things update
 
in there debugger you can add your own
 
variables to make it easier for you to do things
 
let's add a variable for the glass bowl
 
and another one for the plastic bowl
 
so this is the name of the variable, colon,
 
the type of the variable, then action you can
 
there are three collections
 
m1 m2 and m3 that you can easily assign to
 
from the selected things in the
 
result list, so this will give you a good
 
way to access specific objects, so let's
 
see if I manage to assign the glass bowl
 
to m1 and then the plastic bowl to m2,
 
which I selected, like that
 
these are actually collections of one
 
no, there are objects, sorry
 
so the glass bowl is of type "fruit
 
bowl" so it has property contains this fruit
 
and you can follow the associations, ocl
 
editor is acting up them I'm taking
 
I'm taking notes to fix these after I've done this presentation
 
so what I really want to do now is to show you some of the
 
operators that work on collections
 
so we have the union of
 
course, we saw that before and
 
we also have an operator called intersection
 
that use fo from time-to-time
 
intersection is, well it's the intersection between
 
two collections, so what equals the two collections
 
what thing is in both, so if I do the
 
glass bowl and a collection with orange all instances
 
I will get all oranges in the glass bowl, fruit all instances will
 
of course return all the contents of the
 
glass bow,l because there's nothing else than fruit in it
 
another operator symmetric difference
 
the sets contain and contain all the elements that are
 
in set two, and set one and set two, but not in both
 
so this will be the all the fruits that aren't assigned any fruit bowl all the apples
 
so and I want you to get to know these
 
operators as they will help you to
 
express yourself and to get the business
 
rules, that you're after in an efficient manner
 
yet another operator is the difference
 
it's like the symmetric difference but
 
it's trickier, because it's not symmetric
 
so you need to take care of what
 
collection you put aware, so if you flip this around
 
you will get another very different result the collection one and
 
the collection two that is, so again just try them out
 
it's easy to to do in the debugger and
 
then I will close this session and get
 
right back with the third part

Latest revision as of 15:44, 10 February 2024

An introduction to OCL - the Object Constraint Language - through an example. This session introduces the new MDriven Debugger and shows how to get instant results from modeling efforts. This particular session explains the configuration of different operators, the concept of derivation, and the principles of various OCL association tools through a practical example. It is as clear and understandable as possible to learn or be taught with.

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 video. Now you can pick any topic to be instructed on without watching the whole video.

This part includes an overview on: code comments associations temporary variables introduction (temp operator) add operator at(0) operator derivation asCommaList operator if operator groupby operator sum operator add criteria to the grouping adding variables m1, m2, m3 collections Collection operators symmetric difference operator difference operator

This page was edited 99 days ago on 02/10/2024. What links here