1.53 design: Root and Child interaction to create new child

1.53 design: Root and Child interaction to create new child

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


esteban404 posted on Wednesday, July 26, 2006

At first I thought my model would be similar to the Resource, ProjectResource, ProjectResources we've all seen, but I see now it's not quite a match and I'm stumped. The final output of this process is a concatenation of several fields: Prefix, ProgramID and suffix. Together they are an alphanumeric identifier on which an item we sell will be based, so it's a very important process to keep simple yet tight.

After loading the Program object, I'm not sure how to create an object of the Tool type using the data from program. Or if I should. For example:

...
Tool t = Tool.NewPrototypTool(string prefix, string programID, string suffix);
t.Save();

//reload the collection
this._tools = Tools.GetTools(_programID);
...

If this is close, is this just a method within my Program class? I'm not sure

If it belongs in the Program object, how would the factory work? This seems wrong especiall the saving of the data in another object, but it's new to me:
public static Program NewPrototypeTool(string prefix, string programID, string suffix)
{
 Tool t = Tool.NewPrototypTool(prefix, programID, suffix);
 t.Save();
 
 //reload into collection
 this._tools.Add(tool);
}

Any thoughts on the direction here? Doesn't seem like this belongs in the object, but no other object will be as aware of the constraining data inputs. (I'll also need to allow for manual input for legacy stuff. I'm not looking forward to that, but that'll be Excel based I hope.)

I'm not sure, but I believe the prefix will need to come from the user. It's a manufacturing process type enum. I could always change the factory to allow a change like a Resources' role can change.

Thanks in advance,

_E

vargasbo replied on Wednesday, July 26, 2006

If I understand what you're doing. You're saying you have a Program, which already has it's properties filled out, you then want to create a new tool and want to pass in values from it's parent? The child already know who's his parent is, so you can just make the call to the parent and pulls those values in your new object, i usually do this before i save. It's talked about in the book, search for parent. Make sure you add the two attributes which prevent it from going into a stackoverflow.

Regards,

esteban404 replied on Wednesday, July 26, 2006

I found the missing part. It has to happen in the UI because a piece of it is determined by the user and does not exist in the object. So, I added a couple of method to return the properties required and then pass the completed settings to the factory. It should be documented well enough to make sense if i'm no doing the UI. They'll have to make use of a dialog box to get the settings then pop open the object editor.

I don't recall seeing the discussion you mentioned in the book. I have both books, so I'll look harder for stack references.

Thanks for the reply,

_E

Copyright (c) Marimer LLC