### Computational Physics Spring 1998

#### W. Christian

 Building a User Interface First Program Regression ODE Laplace's Equation Complex Class Final Project Poster Session on May 5
Student Solutions to Previous Homework

### Linear LINEAR plots two linear equations and calculates their intersection. The program does this simple job well. It is clean, attractive and easy to use.

Linear_98.ZIP Source code. Linear_98.EXE (472K) Run the application.

## How to Attack the Programming Exercises.

### THINK

Try and do the problem using pencil and paper using a very special case or a small amount of data. This will help you understand the algorithm and generate values that you can use to debug the program.

### ORGANIZE

• Create a separate directory for each programming project.
• Create a new project in Delphi and save this project into the new directory using descriptive file names.

### BUILD A SHELL

• Draw the graphical user interface, GUI.
• Set the initial values for important variables.
• Write Do-Nothing subroutines that show your program's structure. Add a comment to every subroutine declaration to tell yourself what this subroutine will eventually do.
• See if the shell will compile.
• Save your work and make a second backup on floppy disk.

### MAKE IT WORK

• Add the algorithms to make the program do the required calculations. Do the simplest case first.
• Add documentation as you go along explaining what you think the code does.
• Use the debug features of Delphi such as breakpoints, single step, and trace to find bugs.
• Check your results against known solutions.

### MAKE IT USEFUL

• Have a friend test the program and watch what they do without any intervention on your part. Can a new user figure out how to operate the program? Do they like how it looks?
• Try and crash the program. Put in crazy values. Trap for both mathematical singularities and non-physical input.

### LEARN FROM OTHERS

• Read the book. You may not understand everything the author is saying but you can certainly copy source fragments such as how to create a dialog box.
• Look at the sample code that I have posted on the WWW including solutions to previous problems.
• Come by and ask questions.

### THE GOLDEN RULES

1. Do only one change at a time and make sure it works before you go on to the next change.