How would you model an objects representing different phases of an entity life cycle?

Posted by Ophir Yoktan on Programmers See other posts from Programmers or by Ophir Yoktan
Published on 2013-11-11T19:43:46Z Indexed on 2013/11/11 22:12 UTC
Read the original article Hit count: 196

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.

© Programmers or respective owner

Related posts about design-patterns

Related posts about object-oriented-design