lundi 14 janvier 2019

How to design an entity contains fixed child classes

If I have a Policy and this Policy should consist of Sections(fixed number).

My Sections are 4 predefined sections:

  • Work time regulations.
  • Excuses.
  • Shifts.
  • Time-sheets.

Each Section has fixed attributes differ from the attributes in other sections . If I can illustrate it as an analogy:

  • Policy ---> Human body.
  • Sections --->(Arms, Legs, Head)
  • Each section differs from one another Like (head contains eyes, ears,...etc rather than the arms contains two hands)

For example:

  • Work time regulations section has name,list of work-times.
  • Excuses section has numberofhours, reason, excuse_type.

Note: based on the domain expert explanation: He want a Save action with each section (as a draft) so that he can update the section unless the Policy not submitted yet, and a Submit action for the whole Policy so that after the Policy submission No one can update or delete this Policy or its sections. (any required update = Define new Policy)


Now I want to design the Policy, Section and its content. but I'm Stuck.

Firstly I thought I could design Policy as Entity (the aggregate root) and create four classes, one for each Section and inherit them all from Section base class(Id,name), and The Policy contains List of Section.

Am I in the right direction? Could I get some recommendations in my case?

Aucun commentaire:

Enregistrer un commentaire