Make a JavaScript Class Model

Let’s learn about the JavaScript class model and conversion from the information design model to the JavaScript class model.

Steps to making a JavaScript class model

Using the information design model as the starting point, we make a JS class model by performing the following steps:

  1. Create a check operation for each non-derived property so we have a central place for implementing all the constraints defined for a property in the design model. For a standard identifier attribute, such as Book::isbn, two check operations are needed:

    • A basic check operation, such as checkIsbn, for checking all basic constraints of the attribute—except the mandatory value and the uniqueness constraints.
    • An extended check operation, such as checkIsbnAsId, for checking—in addition to the basic constraints—the mandatory value and uniqueness constraints that are required for a standard identifier attribute.
  2. The checkIsbnAsId operation is invoked on user input for the isbn form field in the create book form and also in the setIsbn method. The checkIsbn operation can be used for testing if a value satisfies the syntactic constraints defined for an ISBN.

  3. Create a setter operation for each non-derived, single-valued property. In the setter, the corresponding check operation is invoked, and the property is only set if the check does not detect any constraint violation.

The JavaScript class model

This leads to the JavaScript class model shown on the right-hand side of the mapping arrow in the following figure.

Get hands-on with 1200+ tech skills courses.