Beginners Guide to Dolphin Smalltalk -.:: GEOCITIES.Ws
Total Page:16
File Type:pdf, Size:1020Kb
Beginners Guide to Dolphin Smalltalk Beginner's Guide to Dolphin Smalltalk Welcome to Dolphin Smalltalk for Microsoft Windows 95 and NT. By now, you have probably installed Dolphin onto your computer and are wondering where to go from here. This guide is the place to start. Contents I know you're probably itching to get going, but I'd just like to take time out to tell you about the structure of this guide and the intended audience for the various parts. Chapter 1: Getting Started This chapter will get you started with Dolphin and teach you how to interact (safely) with the system. If you have used Smalltalk before, much of this will be familiar to you so you may just need to skim through this section quickly. The following chapters are a general introduction to the Smalltalk language and, in spirit, are as applicable to any other implementation of Smalltalk as they are to Dolphin. In practice, we'll use a sample application called Playground to illustrate the various topics and currently this is only available in Dolphin Smalltalk. If you are already familiar with the basic Smalltalk language, you may decide to skip over these chapters. Chapter 2: Objects and Messages Chapter 3: Playing with Objects in the Playground Chapter 4: Control Flow Chapter 5: Classes and Methods Chapter 6: Programming in Smalltalk From this point on there are a number of tutorial sessions available to teach you how to use the Model-View-Presenter framework which lies at the heart of building applications in Dolphin. The following chapters are specific to Dolphin Smalltalk. Tutorial 1: Experiments with Simple Windows Tutorial 2: A Scribble Pad Component file:///C|/OADocs/1.htm (1 of 2) [6/2/2000 8:39:12 AM] Beginners Guide to Dolphin Smalltalk Tutorial 3: Etch-A-Sketch Tutorial 4: Creating a Personal Money Application file:///C|/OADocs/1.htm (2 of 2) [6/2/2000 8:39:12 AM] Getting Started Getting Started This chapter gets you started with Dolphin Smalltalk. The installation program will have created a program folder containing a Dolphin icon. Double-click this to start the Dolphin development system. Obtaining Support There may be times when you run across a problem with Dolphin that you can't solve yourself. If so, you can obtain technical support from Object Arts Ltd. by Internet email or by connecting to the special Dolphin newsgroup forum. For more details, please visit the Object Arts Support web page at: http://www.object-arts.com/Support.htm. First Use When you start Dolphin for the first time, you will be presented with two windows: a System Folder window and a Workspace window. The workspace contains a welcome message and some interesting experiments that you can try immediately to get an insight into the interactive nature of the Smalltalk development environment. These experiments consist of executing small pieces of Smalltalk code and displaying the results. Note that the green pieces of text enclosed in quotes are simply comments and not part of the examples themselves. Most of the examples fit on a single line. To execute one (say the first, 3+4) simply place the text cursor anywhere on that line and type Ctrl+D. You'll see the result printed and highlighted at the end of the line. You can then delete the result simply by pressing the Del key and the highlighted text will disappear. file:///C|/OADocs/2.htm (1 of 4) [6/2/2000 8:39:21 AM] Getting Started In some cases, the comment above the example will suggest that you just execute the code without actually displaying a result. You do this by typing Ctrl+E (for Evaluate It) rather than Ctrl+D (for Display It). These commands can also be chosen from the Workspace menu. Simply choose Workspace/Display It or Workspace/Evaluate It as required. For those examples that span several lines you must select and highlight all of the lines before typing Ctrl+D or Ctrl+E. If you are new to Smalltalk, then I don't really expect you to understand how these examples work yet. They are simply there for a bit of amusement and to get you used to using a workspace window. You can close the workspace at anytime and continue with the remainder of this chapter. Opening a new Workspace If you have not already done so, close the example workspace window that you've been using up to now. You should then be left just with the System Folder open. As we've seen, a workspace is a general text window where snippets of Smalltalk code can be edited and executed (in Smalltalk parlance, evaluated). It is one of a number of development tools that Dolphin provides. For the next few chapters we will be using workspaces, almost exclusively, to interact with the system and perform our experiments. At the start of each chapter you'll be asked to open a new workspace in which the work for that chapter will be performed. You can do this by choosing the File/New menu command from any other workspace or Dolphin development tool window. You may also use the New Workspace toolbar button or the Ctrl+N shortcut if you prefer. At the end of each chapter you should probably tidy up by closing the workspace (and any other example windows) that you have been using. This will free up any memory space and leave the system ready for continuing with the subsequent chapters. Exiting Dolphin You can leave Dolphin at any time by choosing File/Exit Dolphin in any of the development tools. Alternatively, you can also ask to quit by closing the System Folder window. As you do so, you will be prompted and asked if you wish to save the image. Under normal circumstances you will opt to do so, since this will save the state of your environment such that it will be fully restored next time you start Dolphin up. Try exiting and re-starting Dolphin now, saving the image in the process. The Image When Dolphin is loaded and running there are many objects in memory that make up the essence of the entire system. I will talk more about what objects are in the next chapter on Objects and Messages. However, for the moment, it is important to know that when you choose to save the Dolphin image you are requesting that all these objects be saved to disk in, what is known as, an image file. This allows the system to be re-started in an identical state to that when the image was saved. When should I save my Image? The image contains not only those objects that you may create yourself but also very many objects that are concerned with the Dolphin development system itself. This is a really flexible system since virtually everything is exposed to you and you can make changes that affect not only the program you may be building but also any of the development tools themselves. This can allow you to tailor the system in ways that are not possible with traditional development environments. However, this flexibility also brings with it certain dangers. You may, by accident, make a change that corrupts your image such that the development tools no longer work. For this reason, it is always important that you have a good saved image to go back to. I'd recommend that you save your image, not only when you exit Dolphin, but also quite often during use. I suggest you do this at least every hour and once at the end of each chapter in this guide. Do take care, though, not to save down an image that you might have corrupted in any way. Let's try a simple example to prove the point. Open up a new workspace window and arrange it appropriately on the screen. Now file:///C|/OADocs/2.htm (2 of 4) [6/2/2000 8:39:21 AM] Getting Started save the image using File/Save Image or the Save Image toolbar button (the one with the camera). This will save your current state to an image file on disk. Now let's do some irreparable damage and recover from it. Enter the following line of code into your workspace and evaluate it with Ctrl+E: Processor := nil. You'll see that the development system will crash. This is not surprising really when you consider that you have just instructed the main processing element to disappear. However, now restart Dolphin and you should get back to the same state you were in when you previously saved the image. Backups Ideally, you should also take backups of your Dolphin image files. If you do so, you must always save the following three files together: ● Image file (Dolphin.img) ● Changes file (Dolphin.chg) ● Sources file (Dolphin.sml) You'll find these files in the directory where you chose to install Dolphin itself. If you need to restore a backup (perhaps because you accidentally do save down a corrupt image at some point) then you must make sure that you restore all three files together. These files are inextricably linked and should not be separated. I tend to take a backup of my Dolphin image files daily. The System Folder The System Folder window has been lurking in the background during all of this and we haven't paid much attention to it. In many ways it is launching point for all the tools in the development system. Let us see how this works.