Value Objects and Composite Design Pattern
"Robson" <[email protected]>
| Newsgroups | gmane.comp.programming.domain-driven-design |
|---|---|
| Message-ID | <[email protected]> |
Hi, everybody I'd like to read opinions about this model: 'Survey' HAS A 'SurveyElement', where this one is an implementation of the Composite design pattern. So 'Question' (the leaf) and 'Block' (the composite) implement 'SurveyElement'. I'm treating 'SurveyElement' as a value object, since everytime I edit the survey, a new structure (tree) is created (the 'root' block and all its blocks, questions, blocks inside blocks, so on). In other words, I don't care about life cycle of the structure of survey elements. But, as value object, 'Block' is equal another 'Block' only when the whole tree is equal the tree of the other block. So I must implement 'Equals' considering all this path down the tree (and this may be a slow process). What do you think about that design? Is it 'correct' designing a value object compounded of a list of value objects? I'd appreciate your suggestions and comments. Thanks. ps.: I'm posting this to Domain-Driven Design groups on Yahoo and Google Groups. So please, disconsider one of theirs. ------------------------------------