I have a complex domain model built on top of a legacy system that I've built most of the "get" methods for - typically just by passing around database primary key IDs. Easy enough. I'm now curious how to approach the task of creating new objects in the database and saving existing ones with new data and want to make sure I cover all my bases.
The main domain objects that correspond to entities in the database number around 20-25 for the entire project. About 10 or so will need to be saved (the rest are just there for supporting data and don't need updating by the user). The objects to be saved have complex dependencies - object A has a list of object B which contains objects C, D, and E, for example, all of which might need to be saved when the original object A is.
I'd like to build it so it's easy to use by the UI developer, but also enforces that only valid data gets saved (let's say maybe object B cannot save unless object C is in a valid state). This makes me shy away from allowing them to create an object from scratch and attempt to save it - I want to follow the principle that objects should only ever be alive in a valid state.
The other alternative is exposing "CreateNew" and "Save" methods on the service objects that handle them, but the parameter list for such methods would be egregious.
I'm thinking of requiring "CreateNew" and "Save" to accept something like a command object that they can create and pass so they know exactly what data is needed and what they can't try to control. I read up on the command pattern but I don't need any of the main perks it provides.
What considerations should I have to decide on an approach? This is C#3.5, if that factors into it at all.