Code the Model Classes
Let’s learn how to code the model classes.
We'll cover the following
The JS class model can be directly coded to get the code of the model classes of our JS front-end application.
Summary
- Code the enumeration type
BookCategoryEL
to be used as the range of thecategory
attribute with the help of the meta-classEnumeration
. - Code the model class
Book
in the form of a JS class definition withget
andset
methods as well as staticcheck
functions.
These steps are discussed in more detail in the following sections.
Code the enumeration type BookCategoryEL
The enumeration type BookCategoryEL
is coded with the help of our library meta-class Enumeration
at the beginning of the Book.js
model class file in the following way:
BookCategoryEL = new Enumeration([ "Textbook", "Biography"]);
Code the model class Book
We code the model class Book
in the form of an ES2015 class definition where the category
attribute as well as the segment attributes subjectArea
and about
are optional, with getters, setters, and static check
functions for all properties.
Get hands-on with 1400+ tech skills courses.