domain driven design - In DDD, how do you handle a conceptual object that is somewhere between an Entity and a Value Object? -


in domain model, how treat conceptual object somewhere between entity , value object? i.e, not small; has many attributes, doesn't have identity or meaning in-and-of (i.e. equality based on attributes). because needs have attributes edited via ui, can't see how can made immutable--constantly being destroyed , recreated every time user changes attribute. furthermore, hybrid object intended become entity of either 1 type or another, depending on role in system.

example: recipe class. purpose encapsulate set of instructions carried out machine. 2 different recipe objects equal if collective instructions identical. recipe intended take on 2 entity roles in system:

  1. to used in mastersequence, list of recipe objects executed in sequential order. in case recipe conceptually take on addition attributes such stepnumber , isactive. each of these recipies carries identity (i.e. recipe in step 1 might have identical attributes 1 in step 2, conceptually distinct).
  2. a recipe can saved "favorite recipe" persisted in favorites list. in case recipe has no concept of stepnumber or isactive, rather, simple id gives identity.

in either of these 2 roles, ui needs present dialog box edit attributes of underlying recipe. should 2 entities created, sequencedrecipe , favoriterecipe act wrappers recipe object? , should recipe take on semantics of value object, considering size/complexity , need editing?

i think miss in ubiquitous language distinguish between idea of recipe, i.e. blueprint, , real recipe executed in mastersequence.

the concept of prototype (and design pattern same name) might helpful here.

the recipeprototype entity able spawn new recipe vo when needed. vo incorporated in mastersequence -- way, if original recipe blueprint changed, won't affect existing mastersequences using recipe.

public class recipeprototype {    // recipe fields here    public recipe spawnrecipe() {     // copy , return new recipe vo here   } } 

a favorite recipe reference recipeprototype id.

edit : latest comments realize recipes contained in mastersequence not specific kind of recipe life of own, , original recipe object gets modified.

thus, recipe entity me, there's no value object modification involved whatsoever.

this becomes ui problem -- need have 2 different viewmodels (mastersequencerecipe , favoriterecipe) display map same domain action in modification -- changing recipe entity.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -