The first lecture argued that programming and programming languages are deeply intertwined; programming languages affect how we think about programming, and new programming problems inspire evolution in programming languages. This project explores the relationship between batch (standard textual, sequential) and web programming to set the stage for the programming languages topics that we will cover after the midterm.
We will do the project in two stages. This handout describes the first stage; the second stage handout will be provided after the midterm.
After completing this stage of the assignment, you should be able to:
The project is due September 22 (Saturday) at 11:59pm via turnin (use assignment name project1).
Note that the due date is right before the midterm. We will begin discussing web programming in class the day after the midterm, so you need to have done this project before we discuss web programming in class. Rather than force everyone to turn the project in earlier, I've set the due date to give you flexibility in scheduling your time. However, the due date is a rope don't hang yourself with it. I will not grant extensions on this project unless you have a documented emergency.
If you've never written web pages or scripts, the programming parts of the assignment may be a bit time-consuming. Start early.
This stage has three parts: two programming parts, and one analytical part. Be sure to keep a copy of all work you do on this stage for use in the next stage.
A pizzeria has hired your company to computerize their ordering system. Pizza orders consist of a name, an address, whether the pizza will be picked-up or delivered, a pizza type (thin or stuffed), size (small, medium, large), and a list of toppings (available toppings are mushroom, olive, spinach, egg, sausage, and pepperoni). Your clients want the ordering system to provide a way to save regular customers from having to type in their name and address each time they place an order (this will be called the "personalization feature" in the rest of this document).
Your boss has asked you to produce two prototypes of the interface: one textual and one web-based (the text version will run inside the pizzeria for placing phone orders, while the web version will allow customers to place their orders online). Each prototype will gather the ordering information and display the total cost of the ordered pizza. Your prototypes will not actually store orders; it will only compute the cost of the ordered pizza and display an order summary.
See the interface prototype samples for an idea of what kind of interface we expect you to develop for this assignment. You may develop a fancier interface if you choose, but be aware that it will not earn you extra points towards your project grade.
The cost of a pizza is calculated as follows:
For thin pizzas, the base costs are $8 for small, $10 for medium, and $12 for large.
For stuffed pizzas, the base costs are $10 for small, $12 for medium, and $14 for large.
Meat toppings cost $1.25 each, regardless of pizza style or size. Veggie toppings (including egg) cost $.75 each.
In both programming problems, assume that the user of your programs always enters valid input. You programs do not need to do any error checking.
Write the textual prototype in Scheme. Develop (and use) the following programs as part of your solution:
prompt-read-many : list[string] -> list[symbol]
consumes a list of prompts, presents each prompt in turn and gathers
the data collected into the output list. The answers in the output
list should occur in the same order as their prompts are in the input
list.
Note that this contract implies that we will view addreses as symbols rather than strings. This means that your "address" must be a single sequence of characters (e.g. '100-Institute-Road, not "100 Institute Road"), but this will simplify parts of the project down the road.
Prompt the user for a fixed number of toppings (at least two) in this version.
display-order : list[symbol] list[symbol] -> void
consumes the data that has been entered and displays a summary of the
order including the price of the order. The first input list contains
the name and address information; the second input list contains all
of the remaining information (size, style, toppings, and
pickup/delivery info).
Write the web prototype as a series of forms and scripts using the CGI protocol. You may implement your scripts in any language (Perl, Python, Scheme, etc). The web prototype should support the personalization feature, but without adding more than 8 characters to the ordering pages' URLs (ie, you can't directly embed all of the personalization data in the URL). Ideally, the feature should not require the customer to enter some sort of id or username (such a solution will earn only half-credit on this part of the assignment).
Use two pages for collecting data as shown in the example.
The Links and Hints section further down on this page has pointers to material on CGI scripting.
Based on your two prototypes, answer the following questions:
What language did you use for the web-based program?
What is the URL for trying your web prototype? (for use in grading make sure that your script will run from anywhere on CCC)
Modify both prototypes to contain each of the following errors. In each case, how did you discover that an error occurred and what information did you get to help you locate the source of the error?
How does each prototype communicate the size of pizza ordered to the part of it that computes the final cost?
For each function in your Scheme implementation (including prompt-read-many and display-order), indicate the corresponding construct that implements that function in the web prototype.
Provide instructions for a customer to reuse their name and address information across multiple orders at multiple times (the graders will use these instructions while grading, so make sure they are clear).
Describe your solution (in technical terms, not for a "customer") and justify why it correctly implements the personalization feature.
If you are unable to get this feature working, describe the technical problem(s) that you would have to solve in order to provide this feature. Paraphrasing the assigned problem is insufficient. Your answer should describe precise programming problem(s): for example, "I need to convert a foo into a quux and perform operation baz on quux".
Write a brief (2-3 paragraph) summary of your observations during this project. What do you see as the differences, strengths, and weaknesses of programming in each context (textual and web)? Which context gave you more assistance as a programmer? What challenges exist to programming in each context that doesn't exist in the other?
Your answer should contrast the programming experience in these two contexts. You may discuss features of the languages used for each part, but keep your comments technical (i.e.: statements like "I don't like language X" will cost you points, while comments like "the Y feature of language X made it difficult to generate the data for Z" are fine).
the textual Scheme prototype under filename pizza.ss. The top of this file should contain a comment telling us how to run your program.
copies of all html files and scripts that you wrote for the web prototype. No specific naming convention is required. Also leave the scripts in place in your account so we can test them (starting from the URL supplied in the report).
a single text file (under filename report.txt) containing your answers to the questions about your two prototypes.
Your prototypes will be graded on whether they collect and process the necessary information properly. They will not be graded on their visual appearance. In contrast, adding features while your program isn't yet robust will cost you points.
We will grade your report for writing (complete sentences, spelling, punctuation, clarity, etc) as well as technical content.
We will look for whether you followed good coding practices, such as uses of helper functions, in your prototypes. Remember that there will be a second part to this assignment; you don't know what we will ask you to change for the second part, so try to structure your code so as to localize potential changes.
We expect you to follow the Laws of Homework on this assignment, with the exception that you may use the I/O primitives and begin.
Suggestions for links to additional tutorials and pages that you find useful in doing this assignment are welcome.
CCC's page on using CGI at WPI will help you get started writing CGI scripts. It also explains WPI's policies on running your scripts.
If you use Perl, the sysadmins suggest that you put the following line in your script, right after the #!/usr/local/bin/perl line:
use CGI::Carp 'fatalsToBrowser';
If you search for "cgi" in the DrScheme help-desk, you'll get a tutorial on writing CGI scripts in MzScheme.
A CGI-tutorial from python.org and another intro to writing CGI scripts in Python
For I/O in Scheme, you will most want the commands (all documented in the help-desk):
Example:
(define (age-to-year) (begin (printf "Enter your age: ") (let ([age (read)]) (printf "You were born in ~a or ~a~n" (- 2001 (+ 1 age)) (- 2001 age)))))
This is an individual project. Collaboration is not permitted on this assignment. The course staff are the only people you may approach for help with this project. You may not ask anyone outside of the course staff questions on any aspect of this project, including how to write and run CGI scripts; this includes webmaster@wpi or helpdesk@wpi. If you believe there's a problem with running CGI scripts from your account that warrants CCC assistance, get permission from the course staff to contact helpdesk.
In particular, do NOT bother webmaster@wpi or helpdesk@wpi if you get an "Internal Server Error" while developing your code. This error likely appears due to a bug in your script, not a problem on the server. If you are convinced you have a server error, contact the course staff before contacting any systems staff.