I'd like to take a moment and
show you the process of creating an object diagram.
You might also hear this process referred to as object decomposition.
That is, we're taking something that's a big object, like an app,
and we're breaking it down into its individual components.
Now there's no right or wrong way to do this.
If 100 people create an object diagram for an app,
there might be 100 completely different diagrams.
Also, there are some informal and formal ways to create them.
A formal way might be creating an object diagram using
the Universal Modeling Language,
or UML, and an example object diagram's given here on the left.
Now UML as a modeling language contains a bunch of standard symbols and
icons that are helpful for laying out the components of a project.
But for many, UML can be really bulky to work with, and
I fall into that category.
I'm more of a fan of an informal approach that takes some ideas from UML,
but it doesn't get bogged down in the nitty gritty details.
And an example of a more informal object diagram is given here on the right.
So for this example I'm going to take an app that you'll see later called
Alien Adventure.
This is the main screen for the app, and
I can interact with it by tapping on the screen.
And we can see that this robot will animate across the screen, and
there's an alien, there's actually multiple aliens.
And the robot and the alien will have a discussion,
and they'll go back and forth.
And if the robot answers the alien's question correctly, then these little
badges will appear in the lower left hand corner of the screen.
I'm going to stop right here.
At this point we've already seen enough of this app to actually start
the object decomposition process.
So I'm going to open a Google drawing to build the diagram.
But you could use a piece of paper, a napkin,
a tool like draw IO, which I have that opened up in this other tab here.
This is a Draw.IO diagram, or really just
any tool that gives you the ability to put your ideas into a diagram.
Personally I'm a big fan of napkins and I can say from personal experience that
a lot of great ideas I've diagrammed on napkins, and
I'm willing to say that there's probably some other amazing apps out
there that have been diagrammed on napkins but that's a different story.
The first thing we'll start with is the first big object which is
the app itself.
Now the app isn't an actual object in code, but
that's okay, we're going to use it as are starting point.
And if we think about what we saw when we were playing around with the app,
we can start adding those objects to the diagram.
So we know that there's a robot and that there were aliens, so
I'm going to go ahead and make some rectangles to represent those.
And we'll add labels for the robot object and the alien object.
You'll notice that I'm using the singular form of alien and not aliens,
even though there were multiple aliens in the app
if we were to continue playing it.
And this is a personal preference, and it's one of those aspects of UML
that I'm blending with this informal approach.
In UML you typically refer to objects in their singular form.
Also, if I was using a more formal process,
I might use a certain type of symbol for an object maybe a rectangle.
And then a certain type of symbol for a struct like a rounded rectangle.
But again, because we're keeping it pretty informal,
I'm just going to use rectangles for everything.
Now what else did we notice in the app.?
What else seemed to stand out in our mind as a self contained entity?
What else could be considered part of the application?
Some of the things that I can think of are the background.
We also had badges that appeared in the lower left hand corner.
And there was a dialog bubble at the top, and
it consisted of multiple lines of text.
This is a pretty good set of objects to start with.
These were all things that we could clearly see with our eyes.
But there could also be objects that are behind the scenes.
Things that we can't see, but still make up some part of the application itself.
For example, what about the concept of a game world?
Maybe the aliens and the robot and
everything within it can be thought as parts of a game world.
So I am going to go ahead and add a symbol for world to our object diagram.
And adding world here is just another example of what I want to stress to you,
this process is not exact science.
It's a very creative, abstract thinking type of process.
No two people will probably create the same object diagram.
Now I'm going to go ahead and
stop here, in just a moment we're going to refine this diagram.
We're going to think about how the objects are interconnected,
and we're also going to look to see if the objects have similarities,
because that's a big deal when designing apps.
If some of the objects share traits and other similar functionality,
then we can take advantage of that later when we start writing code.