Using the Class Browser to understand Classes, Methods, Instance variables and an introduction into Class hierarchy

Tutorial 4. Class Browser



More Tutorials
C Programming Tutorial
T223

HTML Tutorial & Web Design
T170,T171 and TT180

Search this site

Home

 

Tutorials
| 1. Starting Smalltalk, and Terminology | 2. Precedence Rules | 3. Classes - Strings | 4. Class Browser | 5. Variables | 6. Error Messages | 12. Control Structures | 16. Dialogs | 23. Collection class | 39. OpenGUI |

 

Information
| Smalltalk Books | Student Software & Books | Hints & Tips | Sites | Download Smalltalk | Coloured code | Download Documents | ASCII Codes |

 

Smalltalk Index

 

 

 

Student
Licence Software
at special prices

 

Contents

Introduction

In this lesson you will learn how to use the Class browser. As you progress through the Open University M206 course LearningBooks you will find that this browser becomes more sophisticated, and includes more classes. Most of these changes are listed in the table below. John McGuinn
  • The Classes from previous LBs will also be present. I.e. LB-13 will have Account, Frog, HoverFrog, Toad classes and additional class Object.
  • The majority of these classes are in normal font weight. Do NOT attempt to modify any of these classes, methods or instance variables.
  • Classes, methods, instance variables that are in a bold font. Are provided by the course team for you to amend, or have been added by yourself.
    • These classes usually only appear in a single LearningBook. When you start adding or amending classes, methods etc., keep a record of which book you use or you will waste a lot of time searching through different books looking for your work. See tip below.
Tip Copy this table to a Word processor. Use the 2 blank columns to insert the names of Classes and methods that you write or amend Add other LearningBooks as required. A few minutes work now could save you hours later in the course.
Major Class browser additions
LearningBook The class browser in which classes first appear List Your Classes List Your Methods Buttons
LB-13. Account, Frog, HoverFrog,Toad     Add... Remove View
LB-15. Object.      
LB-17. BlockClosure, Boolean, False, True, Converter, Lesson1, Lesson2.      
LB-21. Magnitude and 11 subclasses. Discusses the introduction of Amphibian class. Abstract class      
LB-22. Amphibian, Behaviour & 2 subclasses, CharTable, Dialog, Character, Date, Time.
Note the introduction of the Amphibian class, totally changes the Frog etc. Hierarchy.
    The View button used with new shows Metaclass
LB-23. ClassDescription, Collection-(Sets & Dictionaries), Lottery, Association.      
LB-24 Collection-(Fixed Size: Arrays & Strings)      
LB-23 Collection-(Ordered & Sorted)      
LB-27 Beverage Customer Customer StaffMember VatLANAdmin VendingMachine VMAccount.
Note Some of this LB may be optional.
    Find, Edit
LB-31 Stream +9 Subclasses.
Note Some of this LB may be optional.
    File
LB-39 Collection-(List, Interval, and Text) AddressBook AddressBookFixedFormat Model +2 Subclasses. Using the GUI      
LB-45 Initially no change. A set of executable files can be downloaded nearer to the end of the course, that will incrementally add additional classes, methods, instance variables and class variables for the final Hospital, MECEBSC systems.      

What is the Class browser used for.

  • Writing amending removing allowable (The ones in bold text):-
    • Methods - Instance and Class.
    • Variables - Instance and Class.
  • A source of information:-
    • See what methods and variables a class has.
    • View the comments for classes, methods and variables.
    • See the hierarchy of classes.

 

Opening the Class Browser

For the exercises you are going to use LB-27. You will be able to confirm what you have learnt so far in Tutorials 1-3.
Do NOT attempt at this stage to alter any of the code in the Class Browser.

 

Exercise 1. Opening the Class Browser
  1. Start the M206 LearningWorks Application.
  2. Select LB-27 Developing Applications.
  3. Click on the Open button.
  4. In the new LB-27 Developing Applications: Practicals and Notes window.
    1. Click and hold down the left mouse button on Section button. (Top right).
    2. Slide the mouse pointer over Vending machine simulation.
    3. Release the mouse button.
  5. In the new LB-27 Developing Applications: Vending machine simulation.
    1. Click on the Class Browser Tab.
    2. In the Class pane click on Account

Class Browser Diagram Description

The Class Browser window for LB-27 should now look like the following.

{Cass Browser lmage }
The LB-27 Class browser, showing the Account class selected.

Tip. When working in the class browser it helps to enlarge the size of the window, a little bit on the width, and a lot on the length.

Towards the end of the course you will be designing windows, with widgets similar to those shown in the Class Browser diagram above.

 

Starting from the top you have 2 Tab widgets, with the Class Browser tab selected. Note that this widget is not available when you start designing your own windows.
The rest of the window is described in the table below.

 

Widget Qty Description
Labels 3 The labels state what the widget below the label contains.
  • Class
  • Instance / Class variables. Depending on selected radio button below.
  • Instance / Class methods. Depending on selected radio button below.
List 1 Class. List all the Classes that are visible at that stage of the course.
  • The Account class has been selected and is highlighted.
  • The list is indented, this indentation shoes the class hierarchy.
  • Selecting a class will alter what appears in the large pane below.
1 Instance / Class variables. Depending on selected radio button below.
  • Lists either the Instance or Class variables.
  • Clicking on a variable in this list will display a comment in the bottom pane.
1 Instance / Class methods. Depending on selected radio button below.
  • Lists either the Instance or Class methods.
  • Clicking on a method in this list will display the method in the bottom pane.
Radio buttons 2 Instance and Class. Only one of these 2 buttons can be selected. They control the labels and contents of the 2 panes above.
Action button 1 Find. Brings up a pop up menu.
  • Class
  • References to selected class
  • References to selected variable
  • References to methods...
  • Implementers of method...
1 Add. Brings up a radio button menu.
  • a class
  • an instance variable
  • an instance method
  • a class variable
  • a class method
and OK and Cancel buttons
1 Remove. Removes variables or methods that are in bold text.
1 View. From LB-22 this button allows you to look at metaclasses for methods like new.
1 Edit. I can't remember using this.
Label 1 A descriptive label for the edit box below.
Edit 1 The contents displayed in this edit box depend on what has been selected in the top 3 list boxes.
 
Exercise 2a. Finding a Class. Technique 1
You could just scroll up and down the list but as there are more than 100 entries a better technique is required.
  • Click in the Class list pane, say on Object, and type in the first letter or 2 of the required class, the list will automatically start to home in.
    • Start to search for Toad, and type t. Toad is found straight away.
    • Start another search by Clicking in the pane. Search for ByteString by typing in by and ByteString is found.
    • Start another search by Clicking in the pane. Search for Character.
      • Type in c finds ClassDescription, continue typing
      • h finds CharTable, continue typing
      • ara finds CharacterArray
      • you can complete the typing but this technique fails to find Character.

 

Exercise 2b. Finding a Class. Technique 2
  • Click on the Find button and hold down the mouse button.
  • Move over Class... and release.
  • Read the text, note how we can use pattern matching.
    • Type in c*
    • Select Character from the list of about 8 classes.
    • Click OK
    • If you had typed in ch* or chara* etc. the list would be shorter.

 

Exercise 3. Finding a Method

 

  • Hold down the left mouse button with the pointer over the Find button.
  • Slide the pointer over Implementors of method...and release.
  • Type in the method name, including the : (colon) if a keyword method.
  • Click OK
    • Search for the following. plus:, holder
      • Note how you have a View window with a single class in the upper pane, and the actual method in the lower pane.
    • Search for the following. at:put:
      • Note how you have a View window with a multiple classes in the upper pane, the method in the lower pane displays the method for the selected class.

 

Exercise 4. Finding Examples of a Method
This is useful to see how a method is used. You can find how the method that you are interested in is used within other methods.
  • Hold down the left mouse button with the pointer over the Find button.
  • Slide the pointer over References to method...and release.
  • Type in the method name, including the : (colon) if a keyword method.
  • Click OK

 

Exercise 5. Class Hierarchy.
This can be seen in the Class pane. Object is at the top of the list. All the other classes are indented.
  • The first indentation shows the direct subclasses of Object. E.g.
    • Account
    • Amphibian. Note you are using the Class browser in LB-27. There was no Amphibian class before LB-21, Frog and Toad classes were direct subclasses of Object class earlier in the course hierarchy
    • Behaviour
    • Beverage
    • Etc.
  • The second indentation shows the direct subclasses of one of the direct subclasses of object.
    • Account does not have any subclasses. Note that if you have created any subclasses for class Account, they will only appear in the LB you used to create them.
    • Amphibian, has direct subclasses of Frog and Toad. (See note above).
    • Behaviour, has a single direct subclass of ClassDescription.
    • Etc.
  • The third indentation, is similar to the second.
    • Frog has a direct subclass of HoverFrog.
    • Note that HoverFrog is NOT a subclass of Toad
Now find your printout of the Collection class hierarchy. Then in the Class browser.
  • Using any of the 3 techniques (Exercises 2a or b) locate the Collection class.
  • Look at the 16 subclasses indented below the Collection class.
  • Compare this to printed diagram that has 19 subclasses of Collection class.
  • This is due to the fact that the printout was produced from the larger list in LB-39, where 3 more classes were added. If you have not spotted them they are listed in the table above, under LB-39.
  • Get a feel and background understanding of this very important class hierarchy, by reading the various comments. At this stage you are not going into any detail. When you reach the various chapters in the M206 course you can repeat these exercises in more detail.
    • Find and verify the abstract classes.
Other classes that the course covers which you could look at are:-
  • Account
  • Boolean
  • Frog, HoverFrog, and Toad. Depending where you are in the course, use a Class brower before LB-21 if required.
  • Dialog- Look at the Class methods.
  • Magnitude and its subclasses, especially
    • Association
    • Character
    • Date Check out the Instance and class variables and methods.
    • Time
    • Plane. The only class method, is very interesting, pay particular attention to how it creates Student. The only class method, is very interesting, pay particular attention to how it creates a plane and sets the flight identifier to aString.
    • Student. The only class method, is very interesting, pay particular attention to how it creates and initializes an instance of Student.

| Home | Previous Tutorial 3. Classes - Strings | Next Tutorial 5. Variables |

 

Top of Page.

 

Sites by John McGuinn . HTML and Web Design | C Programming

Leeds & the UK Tourist Information & guide my home town

Relax in the sun.

Benidorm   Tenerife   San Marino apartments to rent

Holidays and Short Breaks     Manchester Airport

Leeds my home town City of Leeds information  Leeds and Bradford International Airport

AireWeb Web Design
Leeds Web Design Web Designers Hosting Domain names Web site Promotion

Copyright © John McGuinn 2000 - 04