Tuesday, October 9, 2018

Need Advice on Managing a Collection of Mixed Types

Hey all, my team is designing the core domain model for a project in which we have forms that can have one or more rows for entering arbitrary data. We are trying to be DDD. The rows can be numerical, text, or option based. We need to be able to represent this in the model. The form is an aggregate that holds the rows.

My first thought is having all different rows implement `IRow`, then they will be accessed from `form.Rows`. The issue here is that this isn't easily deserialized by Newtonsoft, and it requires constant pattern matching and casting for those looking to use the collection of rows. Each row type has little to no common functionality to use with an interface.

My second thought is to have a collection property for each type of row on the form entity, but this seems messy, and can get out of hand if we add row types in the future.

Any ideas? Thanks!

Need Advice on Managing a Collection of Mixed Types Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team