Back to book


An overview of how inheritance works with the codebots.

Much like the meta-model where entities can have super class or sub-classes, the bot brings this into the actual entity files. Particularly, each entity or partial entity can have one base class, which is a partial entity. A partial entity is much like an entity, except the fact that they can only be considered as an internal node in the inheritance tree.

For example, given an inheritance tree like this:

|__ Student
   |__ Domestic
   |__ International
|__ Staff
   |__ Tutor
   |__ Lecturer

Person, Student and Staff would be partial entities (internal nodes), whereas Domestic, International, Tutor and Lecturer are entities (leaves).

In term of file structure, entities and partial entities are denoted by the same naming convention, e.g. staff.model.ts and tutor.model.ts. However, partial entities are templated as abstract, which means they are not instantiable via new, hence the requirement of a subclass.

At the top of the inheritance tree is an entity class called AbstractModel which can be understood as the base class of all entities in the application. This class contains the most fundamental attributes that are guaranteed to be available in every entity, which are id, created and modified.

  • id denotes the UUID of the instance of the entity itself,
  • created denotes the created date of the instance of the entity, and
  • modified denotes the modified date of the instance of the entity