4.2. Introduction to VisualWorks

VisualWorks is a trademarked product of Cincom Systems, Inc. It is a complete Smalltalk development environment that includes an implementation of the Smalltalk language, a virtual machine for executing Smalltalk code, and a wide assortment of tools for creating applications in Smalltalk.

VisualWorks provides an integrated environment with a so-called Model-View Controller (MVC), a very popular OOP idea created by Smalltalk. VisualWorks provides and runs a virtual machine (object engine) to process the data in a Smalltalk image. Actually, the virtual machine is an executable file that interprets and executes Smalltalk byte-code stored in the image.

To develop a program under the VisualWorks environment, you must

  • make specifications and plan the program.

  • develop a Graphic User Interface by using Paint Canvas.

  • create code for each method and make it the source code for your program, which extends with .sou.

  • compile and interpret the source code into the byte-code, which is called the image file and extends with .im, and run it in the virtual machine.

  • create a change file if you make any modification to your program; this change file is extended with .cha.

When you finish developing a program in the VisualWorks environment, three files should be created: the source file (.sou), the image file (.im), and the change file (.cha). Your image file is a byte-code file that contains all code and environment variables for your program. The change file is a useful file because in the VisualWorks environment, unlike C/C++ or Visual Basic, you cannot store your program at a different catalog, such as the source file, head file, library files, and resource files; you can only store your program in the different namespace or package it into a parcel. The problem is that if you didn't package your program and you are midway through your program development, you will not be able to find your program the next time you start the VisualWorks tool from the default namespaces. When this happens, you have to use the change file to recover your partial program.

4.2.1. VisualWorks Application Framework

VisualWorks provides a Model-View Controller as we mentioned earlier. Similar to the Document-View class in Visual C++, a Domain Model and an Application Model are provided in the VisualWorks environment. The Domain Model stores and operates your program data (application data or user data, not system data). The Application Model provides a user interface, presents your data, and handles the inputs from the user interface. So the analogy between these components is that the Domain Model is mapped to a Document, and the Application Model is mapped to a View. The Controller generally is embedded in the Application Model, and its duty is to coordinate communication between the Domain and Application Models. Figure 4-1 illustrates this structure.


Figure 4-1.


In VisualWorks, the mechanism that the Application Model uses is called an adaptor. An adaptor stands between the specific interfaces of the User Interface (UI) and the domain objects, adapting messages and values so they “fit.” The adaptor is also called a Value Model, and one of the most popular Value Models used in VisualWorks is valueHolder, which can be used to hold a value of a variable or an object. This valueHolder can be considered as a bridge or a temporary control unit between the domain and UI and can be used to monitor and track the state and change of variables and objects. The functionality and the relationship among the UI, Application Model, and valueHolder are shown in Figure 4-2.


Figure 4-2.


The components inserted in the UI are called widgets. These are buttons, labels, text input boxes, and list or combo boxes. The Application Model sets a connection between the attributes (variables or data) in the Domain Model and the widgets (components) in the UI, which belongs to the Application Model. This connection is set up by the Value Models or Value Holders, and these robots monitor the states and the values of all widgets and will inform the Application Model if the expected situation occurred, and the latter will pass messages into the associated attributes in the Domain Model to begin the associated process or response based on the messages.

Different types of communication are needed in VisualWorks, such as setting up dependents and notifications between objects, event-based notifications, and so on. All communications between objects use messages. In some simple applications, no Domain Model is needed; the Application Model is good enough to provide all functionality of the program's implementation.

The current version of VisualWorks is 5i.4. (Version 7.0 is to be released soon.) The current version of ObjectStudio is 6.6. You can install both VisualWorks and ObjectStudio together. All this software can be downloaded free from the Cincom Web site.

4.2.2. Installation of VisualWorks and ObjectStudio[*]

[*] Information for this section from Cincom Systems, Inc. Used by permission.

VisualWorks 5i.4 is a new, complete release of VisualWorks that includes new object engines, updated images, and add-on products. Follow these steps to install VisualWorks.

  • Insert the VisualWorks 5i.4 CD. In most cases, the installer will start automatically. You can double-click the installWin.bat item from the CD drive if the installer doesn't start automatically.

  • On the Windows platform, an initial screen (see Figure 4-3) prompts you to select the products you would like to install. Make your selection and click Next.


    Figure 4-3.


    [*]

    [*] Screen shot from Cincom Systems, Inc. 2001. VisualWorks 5i.4 Installation Guide, p.8. Part no. P46-0105-06. Used by permission.

  • A welcome screen explains the installation process. Make sure the Install radio button is selected, and click Next.

    The Install button is initially selected unless the install.map file cannot be found. This may happen if, for example, you have copied the CD to a hard disk and are running the installer from there. You will be prompted for the root source directory in this case. Specify the directory root <platform>; for example, rootPC (on the CD or source location). The directory contains the install.map file for this platform. Further adjustments may be required, which are not covered in these installation notes.

    Read the instructions displayed on the next screen, then click Next.

  • You are now prompted for the installation directory (see Figure 4-4). Leave the default directory and click Next.


    Figure 4-4.


    [*]

    [*] Screen shot from Cincom Systems, Inc. 2001. VisualWorks 5i.4 Installation Guide, p.9. Part no. P46-0105-06. Used by permission.

  • You are prompted to select the VisualWorks components you want to install on your machine, as shown in Figure 4-5.


    Figure 4-5.


    [*]

    [*] Screen shot from Cincom Systems, Inc. 2001. VisualWorks 5i.4 Installation Guide, p.10. Used by permission.

    Select at least the Base VisualWorks component, the VM Base component, DLL&C Connect component, and DST component. You also need to select Opentalk, PlugIn, and VisualWave Web Toolkit if you want to develop some Web-related programs.

    Click Finish when you complete your selection. The files will be installed.

  • The system registry will be updated automatically when the installation is finished.

Please note that when you download VisualWorks 5i.4 or other software, no installer program is provided. You need to extract the files from the compressed zip files and configure VisualWorks as follows:

  • Create an installation folder called vw5i4 (C:vw5i4).

  • Download the compressed files to the installation folder.

  • The product is divided into several files, and you probably don't need to download them all. You do need at least the Base VisualWorks and a virtual machine file. The files are described on the download page to guide your selection.

  • Start WinZip 7.0 or later. Open Options|Configuration|Miscellaneous, and uncheck TAR file smart CR/LF conversion.

  • Open the Base VisualWorks downloaded file in WinZip.

    You will be prompted whether WinZip should decompress the single file into a temporary folder and open it. Click Yes. The temporary file is created in C:Windows emp, and has the same filename except for a .tar extension. This file will be deleted when WinZip exits.

    WinZip then displays the contents of the .tar file.

  • Extract the contained files into the installation directory (C:vw5i4).

  • Repeat steps 3 and 4 for each of the other files as well, selecting the same installation directory each time (C:vw5i4).

  • Explore the vw5i4image directory, select visual.im, and double-click it. The .im file type so far should have no association, so a prompter opens asking for the executable.

  • Click other . . . to open a file browser. Find and select visual.exe (may be in C:vw5i4inwin), and click Open.

  • Click the Always use this program . . . checkbox, and click OK.

VisualWorks is now installed, and you can launch it by double-clicking an image (.im) file in Windows Explorer.

4.2.3. Starting VisualWorks for the First Time

With VisualWorks installed, you can launch a VisualWorks session. The virtual machine name is visual.exe, and the initial image file is visual.im (visualnc.im if you are using the noncommercial version) that is installed in the image subdirectory. This image file is an initial file and is write-protected, so you should never override its contents. Instead, you will need to save your image file under a different name by using the save as command, which we will discuss next.

Double-click the VisualWorks icon on the desktop or from Windows Explorer to launch VisualWorks. Two windows will be displayed on screen as shown in Figures 4-6(a) and (b).


Figure 4-6(a).



Figure 4-6(b).


For the noncommercial VisualWorks, an NC license agreement is displayed; read it and click I Accept.

Figure 4-6(a) is the Visual Launcher, which is the main window where most functionalities and controls are located, and Figure 4-6(b) is a workspace window.

The first thing we need to do is to confirm or maybe set up the home directory of VisualWorks. The correct home directory for VisualWorks should be C:vw5i4. Select the File|Set VisualWorks Home menu items from the Visual Launcher. A setup window appears, as shown in Figure 4-7.


Figure 4-7.


Make sure that the default home directory, C:vw5i.4 (C:vw5i.4nc for noncommercial) is displayed in the textbox. This directory is written into the system registry file when you install the VisualWorks software, so we have to make sure of the correctness of this home directory. Click OK if everything is fine.

The second thing we need to do is to create a new working image file for your program. As we mentioned previously, the initial image file is named visual.im, which is the first and default image file when you start VisualWorks, and it is write-protected. You cannot override it with your program image file, otherwise, the system will not start correctly. To create a new working image file for your program, select File|Save As . . . from the Visual Launcher (top window), and a dialog box appears, as shown in Figure 4-8.


Figure 4-8.


Enter a name for your image, such as work, and click OK. This will save the image as work.im and create a work.cha file for your application. Enter only the name for your image and the change file; don't add any extension such as .im or .cha. The third thing we need to do is to load the parcels. The parcels are external Smalltalk binary and source code modules, which are similar to the libraries in Visual C++. Most components are stored in parcels, such as DLL&C Connect, Database, Open Talk, PlugIn, VisualWave, UIPainter, and DST. By placing these parcels in separately, VisualWorks can organize the files more easily. The advantage of loading parcels is that it is much faster than loading and compiling the source code.

We need to load the following parcels for our application:

  • Graphic User Designer (UIPainter 5i.4)

  • DLL&C Connect (DLLCC 5i.4)

The first parcel is used to design our user interface, and the second one is used to develop the interface between Smalltalk and C/C++. To load these two parcels, do the following:

  • Start VisualWorks, click Tools|Load Parcel Named . . . from the Visual Launcher (top window).

  • A Load Parcel Named dialog box appears. The default name for the input box is a *. Keep this * unchanged and click OK to list all parcels on the parcel path.

  • Scroll down on the list until you find the item DLLCC 5i.4, and select it as shown in Figure 4-9. In the same way, select the next item, UIPainter 5i4. Click OK to load these two parcels.


    Figure 4-9.


Now, our VisualWorks working environment is set up, and we can begin to develop our applications.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.123.252