Example: Extending the class Object
A class extension partitions groups of methods (or behavior) for the same class across multiple applications. Multiple extensions to the same class can exist at the same time in your image. You can see an example of multiple extensions when browsing the class Object in a Classes Browser. In the Smalltalk development environment, the class Object is defined in the subapplication Core, and extended in subapplications CLDT and CLIM. The behavior in class Object that supports CLDT and CLIM is partitioned into those subapplications for flexibility and ease of maintenance. Extending a class also provides a convenient mechanism to add (not modify) behavior to the base system classes (for example, within the application Kernel).
Suppose that you want to add a method to Object. You can add to the behavior of class Object; but you can modify only the class or add to its parent subapplication if you have privileges to do so. If you do not have such privileges, you can extend Object in your application, and then add the necessary method to the extension. To extend Object from DevelopChooser, do the following:
1. Verify in an Application Manager that DevelopChooser is an edition. If DevelopChooser is a version, create an edition of it. To do this from an Application Manager or Applications Browser, select DevelopChooser; then select Create New Edition from the Applications menu. After you complete work on the application, you will have to create a new version of it.
2. Open a standard Application Browser on DevelopChooser.
3. From the Classes menu, select Add > Extension. A dialog asks you for the name of the class to extend.
4. Type Object; then select OK or press Enter. The status bar along the bottom of the window, which formerly read Object Undefined, now reads Object(edition timestamp) (Extended) in DevelopChooser. If you look at an Application Manager, you can now see the new edition of Object listed in the list of classes. Note that the Application Manager does not state whether the class is defined or extended.
Last modified date: 10/12/2017