So we have our object diagram started.
And right now these objects are just kind of floating around.
We haven't really talked about how they might be interconnected.
So let's add some connections or if we're going to use the more formal term,
we'll say, let's add some relationships.
Relationships that we're going to add are going to ones that we've borrowed
from UML and those are the contains relationship and
the kind of relationship and these are also known by other names.
For instance contains might be known as part of and
a kind of might also be known as a type of.
And there's other variations too.
So what do these mean?
Let's start with the contains relationship.
Like it sounds, a contains relationship is representative of when an object
contains another object.
If we think about the world object, it contains a robot,
it contains an alien, has a background.
Also has a dialogue bubble and the.
But we're going to leave those out for now.
So in our diagram, let's create some relationships between the world and
the robot, the alien and the background.
So I'm going to go ahead and
move some things around just to make some extra space.
And to represent the contains relationship,
we'll draw arrows from the world object to the objects that it contains and
label them as contains relationships.
Pay close attention to the direction of the arrows.
For these relationships, it's pointing from the world to the robot,
to the alien, and to the background.
And the reason that it points in this direction is it allows us to
read the relationship by just following the arrow.
Now we could also said that the app contains
each of the objects in this diagram, but if I'm going to add an arrow for
every single object in our diagram, it could get a little hard to follow.
So to keep our diagram simple we just want to add the contains relationships
from the app to the most high level objects.
By high level I mean objects that are bigger in the sense that they have more
complexity about them.
So for instance the World object is at a higher level than the Alien object in
the sense that it probably has more functionality contained within it.
Another way to think about it is that the World probably plays a bigger role
as part of the app than the Alien does.
In general you want to keep this going from the most high level object like
In this case the alien aventure to the lower level objects.
So for instance an alien adventure consists or contains a world,
world contains a robot, robot can contain a badge and
we can add a relationship for that later.
Now the distinctions that we're making here in these relationships that
we're adding again they're completely up to you.
Where I'm using a contains relationship between the world and the alien, you
might use something else, or you might not even have a relationship at all.
Or we're on labeling this is a contains relationship.
I might not even have that.
I might even remove an alien adventure.
Because the world is kind of the most high level object and
by the title here we know that we're talking about the alien adventure app.
But again it's just personal preference, you can do whatever you want to.
So moving on, let's talk about the other relationship, the kind of relationship.
This is one of my favorites.
It's used to describe objects that have similarities and
it also involves a little bit of abstract thinking.
For instance let's think about the alien and
the robot, they're actually pretty similar, the robot and the alien.
And can animate, we saw that the robot could move across the screen and
the alien is animating right now.
And they're both able to speak to each other,
so in a sense they're a little bit like actors in a play.
Now this is the abstract part, the aliens and the robot are like actors in
a play, then why not add an object to or diagram that represents an actor.
I mean that sounds pretty good to me,
an actor is an object they can be animated and participates in discussions
and just like we said both the alien and the robot are kinds of actors.
And that's how we'll add this kind of relationship.
We'll start by adding an actor to the diagram.
And then we'll add relationships from the alien to the actor because an alien
is a kind of actor.
And from the robot, the actor because the robot is a kind of actor.
And I hope you've noticed that for this kind of relationships,
the direction of the arrows again, we're going from the alien to the actor.
So it reads very naturally an alien is a kind of actor.