In this video, I’d like to show you more
advanced analysis you can do on code with Nautilus.
So let’s open Nautilus. We consider for instance
a simple class, NumberParser.
Now we look at what
we call Senders and Implementors.
Often, we know someone is fluent in Pharo when
he has understood how to use Senders and Implementors
to find information. So let’s have a look:
I consider a method, I’d like to know what
calls this method: what do I do?
I use Senders Of.
What will I get with Senders Of?
I get here only one method
which calls Senders Of, it is called
ReadExponent and it calls ExponentLetters.
It is an interesting information.
Now let’s imagine I go in the public
protocol, I choose NextInteger. I ask the Senders.
I will get this potential
Senders list.
In fact, these are all the places that send the NextInteger message.
Here I see I am in the NumberParser
class, and I call Self.
As I use Self to do a call, it
will necessarily be the method I have here
Now on the packages or the XML class, it is not so
obvious because I don't necessarily know, as Pharo
is a language with no types, I don't know for sure
if this is the method concerned.
In fact, the system shows that a message
with the same name has been sent.
In order to check this, I can for instance
say that I'd like to know
what are the implementors, how many times is
the method implemented in the system.
To do this, I will select Implementors Of.
Implementors Of. Ah bah look, whereas in the other
case I only had one method, so it was necessarily the one
that was called, here I have several ones.
This method, NextInteger, is defined
on NumberParser, but it is also defined on XMLInteger.
XMLInteger is even defined on two different
classes. So I see that these
methods, these calls are message sends
calls and they will be resolved and the methods selected.
You see that Sender and Implementor are
very important. With Implementor you will
see all the system's classes implementing a method.
With Sender you will see all the calls made to a method.
Senders are really very important because
they enable you to look at examples,
to find how a method is invoked.
Here I've selected a method with no argument,
but if I had chosen a method with an argument,
for instance Number, NextNumberBase and I click
on Sender: what will it
show me? I have an argument, and I see it is
the base.
Here it appears it is not an argument,
it is just a call that has an argument.
But in this test here, I see that
if I instantiate NumberParser on Stream,
and then I send it the message NextNumberBase
and the argument 10.
It makes me understand how
I have to use the API.
It is so much used that there are keyboard shortcuts.
Nautilus was first designed so that you can
do all these operations without touching the mouse.
Here notice that B means browse.
So we will do Browse Sender, N is for Sender's N.
Browse Implementor, M is for Implementor.
If I select only "NextNumber" for instance,
and I do Browse N, I will get
NextNumber's Senders.
In the same way, if I select I get them.
Now if I want to get the Implementors, Browse M,
I get the Implementors.
In the same way about classes, I'd like
to know what are the other system classes using
NumberParser. To know this,
I select Analyze, I have Class
references. And I get all
the classes. I get all the methods using...
Here I see they are mainly tests.
Look: in ClassInteger, I call
the Parser.
Here, the tip to understand is to remember the
keyboard shortcut,
Browse shift N, with a
capital letter because it is the same as to
invoke a method, except here we want
to invoke a class and a class is bigger than
a method, so we have a capital letter.