Chapter 10. Practice Projects

Table of Contents

1. Project 1 - Ratings and Genres as Enumeration Attributes of Movie
2. Project 2 - Country Code and Religions as Enumeration Attributes

In the following practice projects, first make a list of all the constraints that have been expressed in the information model. Then code the app by following the guidance of this tutorial and the Validation Tutorial.

Following the tutorial, you have to take care of

  1. defining the enumeration datatypes with the help of the meta-class Enumeration;

  2. defining attributes together with a check function and a setter method;

  3. extending the class-level data management method update, and the instance-level conversion function toString such that they take care of the added enumeration attributes.

in the model code of your app, while In the user interface ("view") code you have to take care of adding new table columns in the "retrieve and list all" user interface, and suitable form controls (such as selection lists, radio button groups or checkbox groups) in the "create" and "upate" user interfaces.

Make sure that your pages comply with the XML syntax of HTML5 by means of XHTML5 validation (setting the validator field Preset to "HTML5 + SVG 1.1 + MathML 3.0"), and that your JavaScript code complies with our Coding Guidelines and is checked with JSLint (http://www.jslint.com).

If you have any questions about how to carry out the following projects, you can ask them on our discussion forum.

If you would like to work on these practice projects with the guidance of a coach, then you should enrol in the introductory online course (book parts 1-3) offered by our partner developer-competence.com.

1. Project 1 - Ratings and Genres as Enumeration Attributes of Movie

The purpose of the app to be built is managing information about movies. The app deals with just one object type, Movie, and with two enumerations, as depicted in the following class diagram. In the subsequent parts of the tutorial, you will extend this simple app by adding actors and directors as further model classes, and the associations between them.

Figure 10.1. The object type Movie defined together with two enumerations.

The object type Movie defined together with two enumerations.

Compared to the practice project of our validation tutorial, two attributes have been added: the optional single-valued enumeration attribute rating, and the multi-valued enumeration attribute genres.

Following the tutorial, you have to take care of

  1. defining the enumeration datatypes MovieRatingEL and GenreEL with the help of the meta-class Enumeration;

  2. defining the single-valued enumeration attribute Movie::rating together with a check and a setter;

  3. defining the multi-valued enumeration attributes Movie::genres together with a check and a setter;

  4. extending the methods Movie.update, and Movie.prototype.toString such that they take care of the added enumeration attributes.

in the model code of your app, while In the user interface ("view") code you have to take care of

  1. adding new table columns in listMovies.html and suitable form controls (such as selection lists, radio button groups or checkbox groups) in createMovie.html and upateMovie.html;

  2. creating output for the new attributes in the method ...view.listMovies.setupUserInterface();

  3. allowing input for the new attributes in the methods ...view.createMovie.setupUserInterface() and ...view.upateMovie.setupUserInterface().

You can use the following sample data for testing your app:

Table 10.1. Sample movie data

Movie ID Title Rating Genres
1 Pulp Fiction R Crime, Drama
2 Star Wars PG Action, Adventure, Fantasy, Sci-Fi
3 Casablanca PG Drama, Film-Noir, Romance, War
4 The Godfather R Crime, Drama


More movie data can be found on the IMDb website.