|
|
Line 80: |
Line 80: |
| </script> | | </script> |
| </html> | | </html> |
|
| |
| '''Raw subtitles text'''
| |
|
| |
| Hi welcome back to Part3 of Ocl
| |
|
| |
| let's say someone changes the requirements
| |
|
| |
| all of a sudden, the fruit can be in
| |
|
| |
| multiple bowls, so I should have changed
| |
|
| |
| the cardinality of the inbowl
| |
|
| |
| property, but then we need to add a
| |
|
| |
| Association object and association class
| |
|
| |
| called fruit part in this case
| |
|
| |
| I also add a percentage property on it,
| |
|
| |
| so I know how much of the fruit that's in
| |
|
| |
| the fruit bowl and all of a sudden,
| |
|
| |
| we have quite different problem
| |
|
| |
| we need to be able to calculate depending on
| |
|
| |
| how much of the total fruits that's
| |
|
| |
| in the fruit bowl, so fruit.allinstances
| |
|
| |
| but we also have the link end
| |
|
| |
| so if we watched the innerlink name
| |
|
| |
| so these are the names to the fruit part in the association
| |
|
| |
| so we find that fruit part
| |
|
| |
| so fruit.allinstances and fruit part the
| |
|
| |
| percentage, so if we select this you
| |
|
| |
| should see, ok,okay I have the fruit allinstances
| |
|
| |
| but since I changed the model
| |
|
| |
| so all the data I had before is gone
| |
|
| |
| so I need to update it
| |
|
| |
| ok let's add a new attribute, so that we
| |
|
| |
| know how much of the fruit is in bowls
| |
|
| |
| since the fruit is one fruit hundred
| |
|
| |
| percent it shouldn't be more than a hundred
| |
|
| |
| so we have the fruit parts that
| |
|
| |
| this fruit takes part in and the
| |
|
| |
| percentage of that and we sum that together
| |
|
| |
| yeah we need to reload the model had
| |
|
| |
| some changes, saving those okay then
| |
|
| |
| I want to, the fruit I want to assign a
| |
|
| |
| value to the percentage one just use a
| |
|
| |
| random value to get some spreading my
| |
|
| |
| data, so this is issuing the ocl editor
| |
|
| |
| tend to the percentage int32.random
| |
|
| |
| there should be random operator
| |
|
| |
| the max value is a hundred so anything
| |
|
| |
| between 0 and a hundred, execute that on
| |
|
| |
| this glass bowl, okay and on the plastic bowl
| |
|
| |
| oh I add semicolon too much
| |
|
| |
| ok so now we have some random value in
| |
|
| |
| the percentage in the fruit part now
| |
|
| |
| we can make some use in the derivation of
| |
|
| |
| the weight of the contents of the fruit bowl
| |
|
| |
| because this is currently not
| |
|
| |
| correct just summing up the weight of the fruits
| |
|
| |
| we need to consider the part
| |
|
| |
| of the fruits that that we use
| |
|
| |
| so we iterate over fruit part the percentage
| |
|
| |
| then we divide that by hundred to get a
| |
|
| |
| fraction and we multiply it with now we
| |
|
| |
| can follow the single link back to fruitInBowl
| |
|
| |
| and get the weight of the
| |
|
| |
| of the whole fruit
| |
|
| |
| and we need to sum that up but that
| |
|
| |
| would be a double and we need an int 32
| |
|
| |
| so we need first to convert it to a
| |
|
| |
| decimal, because that's the highest
| |
|
| |
| position and then we can take it to int32 like that
| |
|
| |
| ok so now we fix that one
| |
|
| |
| let's see how much is in the bowls
| |
|
| |
| so are there any bowls that
| |
|
| |
| oh I should use two errors in
| |
|
| |
| this expression is no one meant I meant
| |
|
| |
| first of all this is spelled like wrong
| |
|
| |
| but what the type is, ok that's the error it was fruit bowl
| |
|
| |
| should have been fruit
| |
|
| |
| okay how much is using bowls, if its
| |
|
| |
| larger than a hundred then that fruit is overused
| |
|
| |
| so we could warn about this in
| |
|
| |
| our application of course, now I have the weight of the
| |
|
| |
| contents as actually and considering the
| |
|
| |
| the percentage of the fruit that's in
| |
|
| |
| there the bowl, let's see what's this then
| |
|
| |
| adding a new derived attribute and
| |
|
| |
| presentation and grab the type name
| |
|
| |
| from the fruit that's in the single link
| |
|
| |
| fruit bowl, that's not like that with
| |
|
| |
| weight of and same thing here back to
| |
|
| |
| the single link fruitInBowl weight
| |
|
| |
| but we want to multiply it by our percentage
| |
|
| |
| how much did we use
| |
|
| |
| ok let's do this, we calculate the actual weight
| |
|
| |
| in separate drived attribute
| |
|
| |
| fruit inbowl, weight, times percentage
| |
|
| |
| devided by hundred, to decimal, we need to go to decimal
| |
|
| |
| because there's the conversion
| |
|
| |
| to int32 is from decimal, ok it's the actual
| |
|
| |
| weight now we have that and we can head back
| |
|
| |
| yeah we have an error in
| |
|
| |
| this expression presentation expression
| |
|
| |
| because you can't just add int32 to a
| |
|
| |
| string, we need to make it ok
| |
|
| |
| and back to the debugger, re-read the model
| |
|
| |
| check the fruit bowl hasn't change
| |
|
| |
| that's because we haven't actually made
| |
|
| |
| use of your presentation on the
| |
|
| |
| fruit part, we're going to need to have
| |
|
| |
| back to fruit bowl, in this one fruitinbowl presentation
| |
|
| |
| that's not correct we should use the
| |
|
| |
| fruit part of that, but we need to say
| |
|
| |
| self in front of it, like so
| |
|
| |
| reloading the model, now we can see that
| |
|
| |
| we have detailed information about
| |
|
| |
| what we actually have in the bowl and since
| |
|
| |
| the weight of the contents now actually
| |
|
| |
| is calculated in the fruit part for each
| |
|
| |
| and the weight of each part is
| |
|
| |
| calculated we might as well just sum
| |
|
| |
| those up to reduced the need for definition
| |
|
| |
| and like that doesn't change anything so
| |
|
| |
| these are some examples on how you can
| |
|
| |
| use ocl to navigate your data to
| |
|
| |
| calculate your data to derive data
| |
|
| |
| new information from your existing data and
| |
|
| |
| there's loads of applications for
| |
|
| |
| this and following these rules you can
| |
|
| |
| actually complete the whole software
| |
|
| |
| system only with business rules
| |
|
| |
| expressed in icl, so hopefully
| |
|
| |
| ypu will check out some of our other videos to
| |
|
| |
| learn more about that, thank you for watching this Ocl introduction
| |