How would you model an objects representing different phases of an entity life cycle?
- by Ophir Yoktan
I believe the scenario is common mostly in business workflows - for example: loan management
the process starts with a loan application, then there's the loan offer, the 'live' loan, and maybe also finished loans.
all these objects are related, and share many fields
all these objects have also many fields that are unique for each entity
the variety of objects maybe large, and the transformation between the may not be linear (for example: a single loan application may end up as several loans of different types)
How would you model this?
some options:
an entity for each type, each containing the relevant fields (possibly grouping related fields as sub entities) - leads to duplication of data.
an entity for each object, but instead of duplicating data, each object has a reference to it's predecessor (the loan doesn't contain the loaner details, but a reference to the loan application) - this causes coupling between the object structure, and the way it was created. if we change the loan application, it shouldn't effect the structure of the loan entity.
one large entity, with fields for the whole life cycle - this can create 'mega objects' with many fields. it also doesn't work well when there's a one to many or many to many relation between the phases.