-Hi. In this video, we are going to have a look at the Inspector tool from Pharo
and how it can help you inspect your objects from within
and have a real close look
at how they work and how you can interact with them.
In order to use it,
I put up an expression that you certainly will not see in real life.
Basically, it is an "OrderedDictionary" with three key values.
Under the key "Time", I put the "Time now",
under the "Date", the "Date today",
and under a "Morph" key, I put an "HSVAColorSelectorMorph".
We will see what it looks like later on.
If I want to open the Inspector on this particular object,
I can right-click and go to "Inspect it"
or simply press the shortcut Cmd+I.
So, let's click on it.
We can see that the Inspector is now open.
I will just tidy the Playground.
Now the Items tab is really interesting but we will go over the Row tab first.
The Row tab shows you the actual limitation of the "OrderedDictionary".
For example,
we have got the self representation
being the OrderedDictionary with the three pairs of key values,
"Time", "time now", "Date", "date today",
and a certain Morph that we will see later.
We have got the dictionary and the ordered keys.
If I click on the dictionary,
we will see that there is another tab that will open on the right.
The nice thing that we can see there is that we can, for example,
click another time on the Array this time.
And we can see that we now have three windows
and we can have a preview of the first one below the window.
I can extend it.
I have got the three views or I can restrict it to the last one.
Right now, I am in the last one
and a nice thing is that I can interact with this Array object
by for example writing "self at: 1"
and I can print this
and it will say that 1 has "Morph"
associated with the "HSVAColorSelectorMorph".
If I want to go back to the other, I can simply drag this back,
put it there or I can close it here
to have our two previous views.
Now, let's close this one,
we will have a closer look to the Items tab
which is not represented in everything.
For example, if I go there and I go to the 1 time,
you can see that we have a different representation.
A nice thing that we can look at is...
Under String,
the items will be the number of the different characters with the index.
Here, for the Array, we will have the index and the different items
and if I go to the items for the OrderedDictionary
and close those too,
you can see that we have three different pairs of key values,
for "Time", we have the "time now", "Date" with "date now",
"Morph" with a certain Morph.
If I click on the "Time" thing,
you can see that we now have a panel open with the time.
We can go over to Details,
I can show you the different keys and things
that are present for the "Time" object.
We can also go there and write "self browse"
and press Cmd+D to do it.
This will open the System Browser on the actual Kernel package
and the Chronology tab.
And we can have a deeper look inside the actual Time class.
Another thing you can do right from within the Inspector
is to go over to the Meta tab.
There, you can access the different methods of "Time"
and its class hierarchy.
So, we can go inside Magnitude, Object or even ProtoObject.
You can filter everything.
For example, if I want to look at duration,
I can see that it will filter everything else out.
We can filter the different classes if you have a complex hierarchy
and now, if we go to "Date",
you can see that this time, I have got another tab called Calendar.
We do not have the tab items anymore
but we have got a calendar tab
that is a special tab made for this subject
that will show us that we are May 10th, 2020
and that it is located here on the calendar.
Now, a nice thing we can see
is that if we go over to the "Morph" object,
it is a really complex object
because we have several bounds.
We do not really know how any of this works,
but we can open it in world. "OpeninWorld".
Let's do that.
We can have a small look at it.
We have got a color selector,
then we have got some kind of selector as well here
and a transparency selector there.
We can see that we can inspect this object from here
by using "SelectedColor".
Now, if we would like to plug this color in the Inspector,
we can right-click
and instead of doing "Do it" or "Print it",
we can press "Do it and go" or Cmd+G.
This will plug the results in the Inspector if I click there.
We can now see that we have got this color right there.
That is really powerful.
Another thing you can do is open the object twice.
If I go there, I will click on "self".
I will remove the first tab.
What we can do, instead of exploring this complex object,
is go to Submorphs.
And on this, I go to Morph.
This is the "HSVAColorSelectorMorph" all together.
Now, we can explore the tree composition
and if I click on, for example, the "HColorSelectorMorph",
it will show me exactly what it is
and I can inspect it,
inspect the raw code of this particular piece of Morph.
I can do the same thing there
and you can see that it will add the different components
or show me exactly what I am looking for.
The Inspector is a really nice way to have a close look at your objects
and interact with them from within them.
You can even interact with the actual hierarchy,
browse for classes.
A nice thing you can do is implement new tabs for your objects,
such as for example the Submorphs tab or the Morph tab,
we had the Calendar tab for the date,
or the items for the different iterables.
So, the Inspector is a really nice way to understand how the objects work.