Recent Changes - Search:

OtherPlaces

PmWiki

pmwiki.org

edit SideBar

CodeForTools

A description of the Window/Tool, how to open it without a menu, and the package/class/methodType(instance or class) where it is located.

A key place to look for tools is DevToolSet and StandardToolSet

  • Workspace
    • "Workspace open"
    • Tools-Base>Workspace
  • Browser
    • "Browser open"
    • Tools-Browser>Browser class
    • or "ToolSet default openClassBrowser
    • System-Applications>ToolSet (default inherited from AppRegistry class, creates a DevToolSet class; then openClassBrowser inherited from StandardToolSet class)
      • System-Applications>AppRegistry
      • Tools-Base>StandardToolSet
  • Transcript
    • Open the older ThreadSafeTranscript (pre v1.3)? Not sure, see issue 4039.
    • Instead of "Transcript open" now must use "TranscriptMorph openWindow", Why make it harder?
  • Test Runner
    • "TestRunner open"
    • SUnit-GUI>TestRunner class
  • Morphs (on the screen)
    • World exploreViewHierarchy (click the GUIs page for details).
  • The 'World' menu (click Menus).
  • FileList
    • "FileList open"
    • Tools-FileList>FileList class
  • save (from the world menu)
    • "Smalltalk saveSession"
    • System-Support>SmalltalkImage instance
  • save and quit
    • "WorldState saveAndQuit"
    • Morphic-Worlds>WorldState class
  • Class details
    • <classname> allInstances. "that's 2 small letter L's followed by one capital 'I'"
    • <classname> subclasses. "immediate"
    • <classname> allSubclasses. "immediate and all below them"
  • Methods
    • <classname> methods. "Not very helpful, because it includes compiled methods".
    • <classname> allMethods. "includes selectors of inherited methods, can be very big list"

On initialize

Pharo By Example, p 32 By convention, if a class defines a method named initialize, it will be called right after the object is created. So, when we evaluate LOCell new, the message initialize will be sent automatically to this newly created object. Initialize methods are used to set up the state of objects, typically to set their instance variables; this is exactly what we are doing here.

The first thing that this method does (line 2) is to execute the initialize method of its superclass, SimpleSwitchMorph. The idea here is that any inherited state will be properly initialized by the initialize method of the superclass. It is always a good idea to initialize inherited state by sending super initialize before doing anything else; we don’t know exactly what SimpleSwitchMorph’s initialize method will do, and we don’t care, but it’s a fair bet that it will set up some instance variables to hold reasonable default values, so we had better call it, or we risk starting in an unclean state.

And... from '''http://web.cecs.pdx.edu/~black/OOP/Tutorial/Squeak%20Worksheet%202.html]] (We are actually using a convention here, since a new object is automatically sent the initialize message. If you look at the new method for Behavior, you will see that it always sends initialize to each new object instance as soon as it is created.)


On super (from http://c2.com/cgi/wiki?SmalltalkTutorial)

self refers to the object whose class contains the method you are presently reading, when you are reading one and encounter the word 'self'. If the object's class has no such method, you must be reading the 'nearest' superclass which does have such a method. super refers to the same object as self.

Read that last sentence 100 times, until you accept it as fact, then move on.

So why have two names for one thing? This is a little hard to follow until you get used to it. 'super' is the same object as self, but when you try to figure out which method the object will execute in response to the message being sent, pretend the object's class didn't have such a method. In other words, if the object's class does have a method for the message you're sending, don't use it. *Always* start looking for the method in the object's superclass.

This is so you can extend your superclass' behavior without having to rewrite it. For example,

  • do the same thing as the superclass, and then some:
 >>aMethod

 super aMethod.
 self doSomeMoreStuff.
  • or, do some new stuff, follow it up with whatever the superclass does:
 >>aMethod

 self doSomeStuff.
 super aMethod.

On collecting garbage

See discussion at http://forum.world.st/kill-9-MyClass-allInstances-td2274682.html Start with

  • Smalltalk garbageCollect
  • Smalltalk garbageCollectMost
  • Smalltalk garbageCollectAndReport
  • PointerFinder on: MyClass allInstances first "change MyClass"

Difference between class variable and class instance variable:

 A class variable exists once per image. 
 A class instance variable exists once per subclass. 

 If your singleton class has no subclasses, it doesn't matter. If it   
 has subclasses, then each subclass will have a different singleton if   
 you use a class instance variable. With a class variable, you only   
 have one singleton for all subclasses. 
Edit - History - Print - Recent Changes - Search
Page last modified on April 25, 2011, at 03:44 PM