Pharo /
CodeForToolsA 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
On initializePharo 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,
>>aMethod super aMethod. self doSomeMoreStuff.
>>aMethod self doSomeStuff. super aMethod. On collecting garbageSee discussion at http://forum.world.st/kill-9-MyClass-allInstances-td2274682.html Start with
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. |