Frenchay Wine Society Application
This application is based on the "Wine Society", which is a mail order wine wholesaler. The main commodity is wine, although the society does sell other kinds of products too. This implementation will consider only wines.
A wine is modelled by about ten attributes, taken from the Society's printed List. Description of the wine model.
Implementation
There are two Perl programs providing two main functions:
- To add new wines to the file. update.pl code This program extracts the data from the URL-encoded data submitted on a form and validates it using regular expressions. If the data is valid, a new record is added to the file. The fields on the records are delimited by tabs. In either case, an HTML document is then output, containing a form with the entered data echoed as values of the fields. If there were any errors detected, these are included in the document.
This design has the benefit of avoiding the need for a separate HTML document containing the form. If no data is submitted, an empty form is returned. If there are errors, the data can be corrected and resubmited. If the next record is similar to the previous record, only the dissimilar fields need to be entered.
- To search for a wine. search.pl code This program also uses a turn-around form, with fields for entering values of specific, searchable fields. The supplied data is validated, and then the whole file of wine records is read, and each matched to the search data entered. Matching records are printed in the output document, which also contains the form and the original search data.
This implementation has a number of obvious defects. In the assignment, good marks will be able to be gained by an application which provides the same facilities, but top marks will be awarded to applications which handle some of the defects:
- There is no security - any user can add new wines.
- There is no way to amend an existing record once it has been written.
- There is no check that the reference field is unique.
- The application provides only textural data - many commodities would be better represented by images as well, perhaps even sounds.
Ongoing development of this case study