. .


ST 4U 369: Extending a Class in VA

April 12, 2013 10:45:46.655

Today's Smalltalk 4 You looks at extending an existing class (i.e., adding new methods) in your own application in VA Smalltalk. Doing this allows you to version your changes without making changes to applications delivered by your vendor. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:


If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

When you're extending a Smalltalk class, there are a few different approaches:

  • Subclass and modify in the subclass
  • Extend an existing class by adding new methods
  • Modify the existing class by changing the existing methods and/or class definition

In VA Smalltalk, doing the third requires you to change the owning (i.e., probably system) application. However, you can add new methods into your own applications easily, and that's what we'll look at today. First, create a new application. Then, in the class pane of the browser, pop up the context menu:


After you've created the extension, you can add new methods to the class in question. Here, we've added #cubed to Number:


The important thing to keep in mind is that you can version and release extensions like this without touching the applications delivered by Instantiations. If you can, it's safer to develop in this way. Sometimes overrides are necessary, but they do cause some headaches when it's time to upgrade to a new version from the vendor.

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Tags: , ,

[st4u369-iPhone.m4v ( Size: 1373472 )]

posted by James Robertson

 Share Tweet This