Next Previous Up Top Contents Index

3 Improving The Design

3.2 Starting the application

As you add source code to the files in your project, there will be times when you want to build the project to test it. This section defines some methods that let you run the application in a clean way. Add these methods to frame.dylan.

The frame class that is used to implement the task list manager is called <task-frame>. This class will be introduced in Section 3.4 on page 14. You can define a method to create an instance of <task-frame> as follows:

define method start-task () => ()
  let frame
    = make(<task-frame>);
  start-frame(frame);
end method start-task;

This method is provided as a convenient way to create the frame and then start its event loop. It returns when the event loop shuts down.

Note: Obviously, you should not call this method until you have defined a frame class called <task-frame>.

Finally, you can start the application with the following method, and its subsequent call:

define method main (arguments :: <sequence>) => ()
  // handle the arguments
  start-task();
end method main;

begin main(application-arguments()) // Start the application! end;

Make sure that this is the very last definition in the file frame.dylan, and remember that frame.dylan should itself be the last file listed in the project window.

Once you have added these methods to your code, you can compile and link the code, and run the application to test it, using the appropriate commands in the Dylan environment.

Note that, unlike languages such as C, Dylan does not insist on a single entrance point to an application such as the one given here. All the same, it is still good practice to define one if you can. The main difference between the use of the method main here, and the use of the main function in C, is in the arguments that need to be passed. In C, you need to pass two generic arguments: argc, which specifies the number of arguments you are passing, and argv, an array of strings that define the arguments themselves. In Dylan, however, you only need to pass the second of these arguments; since any Dylan collection already knows its own size, you do not need to pass the number of arguments as an additional parameter.


Building Applications Using DUIM - 26 May 1999

Next Previous Up Top Contents Index