Skip to main content
Engineering LibreTexts

1.8: Finding Classes

  • Page ID
    37362
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)

    There are several ways to find a class in Squeak. The first, as we have just seen above, is to know (or guess) what category it is in, and to navigate to it using the browser.

    A second way is to send the browse message to the class, asking it to open a browser on itself. Suppose we want to browse the class Boolean.

    \(\bigstar\) Type Boolean browse into a workspace and do it.

    A browser will open on the Boolean class (Figure \(\PageIndex{1}\)). There is also a keyboard shortcut CMD–b (browse) that you can use in any tool where you find a class name; select the name and type CMD–b.

    \(\bigstar\) Use the keyboard shortcut to browse the class Boolean.

    Notice that when the Boolean class is selected but no protocol or method is selected, two panes rather than one appear below the four panes at the top (Figure \(\PageIndex{1}\)). The upper one contains the class definition. This is nothing more than an ordinary Smalltalk message that is sent to the parent class, asking it to create a subclass. Here we see that the class Object is being asked to create a subclass named Boolean with no instance variables, class variables or “pool dictionaries”, and to put the class Boolean in the Kernel-Objects category.

    The lower pane shows the class comment — a piece of plain text describing the class. If you click on the ? at the bottom of the class pane, you can see the class comment in a dedicated pane.

    The system browser showing the definition of class Boolean.
    Figure \(\PageIndex{1}\): The system browser showing the definition of class Boolean.

    If you would like to explore Squeak’s inheritance hierarchy, the hierarchy browser can help you. This can be useful if you are looking for an unknown subclass or superclass of a known class. The hierarchy browser is like the system browser, except that the list of classes is arranged as an indented tree mirroring the inheritance hierarchy.

    \(\bigstar\) Click on hierarchy in the browser while the class Boolean is selected.

    This will open a hierarchy browser showing the superclasses and subclasses of Boolean. Navigate to the immediate superclass and subclasses of Boolean.

    Often, the fastest way to find a class is to search for it by name. For example, suppose that you are looking for some unknown class that represents dates and times.

    \(\bigstar\) Put the mouse in the system category pane of the system browser and type CMD–f, or select find class . . . (f) from the yellow-button menu. Type “time” in the dialog box and accept it.

    You will be presented with a list of classes whose names contain “time” (see Figure \(\PageIndex{2}\)). Choose one, say, Time, and the browser will show it, along with a class comment that suggests other classes that might be useful. If you want to browse one of the others, select its name (in any text pane), and type CMD–b.

    Searching for a class by name.
    Figure \(\PageIndex{2}\): Searching for a class by name.

    Note that if you type the complete (and correctly capitalized) name of a class in the find dialog, the browser will go directly to that class without showing you the list of options.


    This page titled 1.8: Finding Classes is shared under a CC BY-SA 3.0 license and was authored, remixed, and/or curated by Andrew P. Black, Stéphane Ducasse, Oscar Nierstrasz, Damien Pollet via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.