New Issues

Let’s learn about some of the new issues that will arise in our new application.

We'll cover the following

New issues in subtyping

Compared to the EnumerationApp, we have to deal with several new issues:

  1. In the model code, we need to do the following:

    1. Add a constraint violation class FrozenValueConstraintViolation to errorTypes.js.
    2. Code the enumeration type to be used as the range of the category attribute (BookCategoryEL in our example).
    3. Code the checkCategory function for the category attribute. In our example, this attribute is optional because the Book segmentation is incomplete. If the segmentation which the Class Hierarchy Merge pattern is applied to is complete, then the category attribute is required.
    4. Code the check functions for all segment properties so that they take category as a second parameter. This is so we may be able to test if the segment property concerned applies to a given instance.
    5. Refine the serialization function toString() by adding a category case distinction (switch) statement to serialize only the segment properties that apply to a given category.
    6. Implement the frozen value constraint for the category attribute in Book.update by updating the category of a book only if it hasn’t yet been defined. This means it can’t be updated anymore as soon as it has been defined.
  2. In the UI code, we need to do the following:

    1. Add a “Special Type” (or “Category”) column to the display table of the List All Books sections in books.html. A book without a special category will have an empty table cell. In contrast, their category will be shown in this cell, along with other segment-specific attribute values for all other books. This requires the corresponding switch statement in pl.v.books.retrieveAndListAll.setupUserInterface in the books.js “View Code” file.
    2. Add a “Special Type” choice widget (typically, a selection list) and the corresponding form fields for all segment properties in the forms of the “Create Book” and “Update Book” sections in books.html. Segment property form fields are only displayed when a corresponding book category has been selected. The approach of rendering specific form fields only on certain conditions is sometimes called dynamic forms.

Get hands-on with 1200+ tech skills courses.