Design Question Parent->Child->(new) Parent

Design Question Parent->Child->(new) Parent

Old forum URL: forums.lhotka.net/forums/t/6745.aspx


detritus posted on Sunday, April 05, 2009

I got a use case giving me some problems, hope somebody can help. Here is the editable objects:
Plan (root)
Participants (child list)
Participant (child)

There are different types of plan and some can contain other people (users). When this happens, I need to create a copy of the original plan and insert it as a new plan (with a reference to the original plan) under the name of the each participant (thus they'll see the plan somebody did in their list).

My first instinct is to handle this in the db with a proc but trying to resist this in order to keep business logic out of db, moreover trying to get rid of my habit of thinking data first as opposed to thinking behavior first in object design as Rocky recommends in some many times, so many places (it's very hard though).

Anyway, another possible way to handle this seems to be in child object factory or data portal methods but that just smells wrong, having child object to create/fill and save a new instance of its parent type. Could somebody help me how to handle this in a "proper" way?

Thanks,

Copyright (c) Marimer LLC