Implement the Class Hierarchy: Model Classes
Explore how to implement a class hierarchy with model classes such as Person, Employee, and Author in plain JavaScript. Understand defining subtype relationships, retrieving instances from persistent storage across related tables, and saving data correctly. This lesson helps you build functional class models and manage application data effectively using inheritance techniques without frameworks.
The JS class model shown below can be directly coded to get the code of the model classesPerson, Employee, and Author as well as for the enumeration type EmployeeCategoryEL.
Define subtype relationships
We define the subtype relationships between Employee and Person, as well as between Author and Person, with extends. For instance, in src/m/Employee.js we define:
Load the instances of the root class
When we retrieve the instances of a class hierarchy’s root class (in our ...