https://wiki.sugarlabs.org/index.php?title=The_Undiscoverable/Squeak/System_Browser_Use&feed=atom&action=historyThe Undiscoverable/Squeak/System Browser Use - Revision history2021-05-14T01:40:13ZRevision history for this page on the wikiMediaWiki 1.35.2https://wiki.sugarlabs.org/index.php?title=The_Undiscoverable/Squeak/System_Browser_Use&diff=82532&oldid=prevMokurai: New stub2012-08-24T21:43:19Z<p>New stub</p>
<p><b>New page</b></p><div>==Getting a System Browser==<br />
<br />
If you open a Squeak session, and click on the Tools tab to open the Tools palette, you can then drag a System Browser to the world desktop. It might look something like this.<br />
<br />
[[File:SqueakSystemBrowserFraction.png]]<br />
<br />
We would like to turn on the Annotation pane in the middle, which is not seen here. To do this, drag out a Preferences window from the Tools palette.<br />
<br />
[[File:SqueakPreferencesBrowsing.png]]<br />
<br />
Select the browsing option at the top, and check the annotationPanes option as shown above. Close both windows and drag out a new System Browser, which will have the pane visible.<br />
<br />
[[File:SqueakSystemBrowserWithAnnotations.png]]<br />
<br />
==System Browser Structure==<br />
<br />
The leftmost pane shows a list of two-part System Category names. The first part of the name is used for grouping system categories together where they have some related function. Thus the Kernel categories refer to objects used to define the base Smalltalk language, while Etoys categories are specific to the Etoys graphical environment. We will focus on Morphic categories, which we will use to define new objects.<br />
<br />
The second part of a category name indicates in a general way what the purpose of the category is. Thus Kernel-Numbers contains all of the different kinds of number used within Smalltalk&mdash;integers, fractions, floating point, complex numbers, and others. If you click to select Kernel-Numbers, the various numeric object type names appear in the second column, the Class pane.<br />
<br />
Selecting one of those object class names brings up displays in the next two columns, for class categories and methods, plus an annotation in the Annotation pane, and a code definition and optionally a comment in the one or two panes below.<br />
<br />
With Fraction selected, we can see this in the code pane.<br />
<br />
Number subclass: #Fraction<br />
instanceVariableNames: 'numerator denominator'<br />
classVariableNames: ''<br />
poolDictionaries: ''<br />
category: 'Kernel-Numbers'<br />
<br />
This shows that there are two internal instance variables for each fraction, the numerator and denominator. Also that this is subclass Fraction in category Kernel-numbers.<br />
<br />
The comment is<br />
<br />
Fraction provides methods for dealing with fractions like 1/3<br />
as fractions (not as 0.33333...). <br />
All public arithmetic operations answer reduced fractions<br />
(see examples).<br />
<br />
instance variables: 'numerator denominator '<br />
<br />
Examples: (note the parentheses required to get the right answers in Smalltalk and Squeak):<br />
<br />
(2/3) + (2/3)<br />
(2/3) + (1/2) "answers shows the reduced fraction" <br />
(2/3) raisedToInteger: 5 "fractions also can have exponents"<br />
<br />
If we click Arithmetic in column 3, we get the message<br />
<br />
message selector and argument names<br />
"comment stating purpose of message"<br />
<br />
| temporary variable names |<br />
statements<br />
<br />
which is a template for defining new methods for the particular object.<br />
<br />
If we click on a method in column 4, we get the code for that method below.<br />
<br />
There is no comment pane shown, but comment text can be included in the body of the code. For example,<br />
<br />
'''negated''' <br />
"Refer to the comment in Number|negated."<br />
<br />
^ Fraction<br />
numerator: numerator negated<br />
denominator: denominator<br />
<br />
tells us that there is a further explanation in the negated method for the Number class.<br />
<br />
'''negated'''<br />
"Answer a Number that is the negation of the receiver."<br />
<br />
^0 - self<br />
<br />
==Creating an Object Class in the System Browser==<br />
<br />
At the top of the scroll bar in the leftmost pane is a menu icon. On that menu<br />
<br />
<br />
<br />
select add item..., which brings up a small window like this, inviting you to name the item (a new category).<br />
<br />
<br />
<br />
Call it Temp, and click Accept.<br />
<br />
{{stub}}</div>Mokurai