Recently someone stated that they thought all Creates should be CreateOrUpdates. Instinctively i thought bad, but now I am trying to find out if I have any grounds.
Situation
interface IService{
void Create(Object a);
void Update(Object a);
}
or
interface IService{
void CreateOrUpdate(Object a);
}
My first thought is if you implemented everything CreateOrUpdate then you have no control if someone accidentally sends you wrong data, or concurrency issues where someone changes a “primary” field right before you call update….
But if you remove those cases, are there any other cons?
It seems pretty simple to me: if you are concerned about accidental record creation use the two methods. If you aren’t concerned use one.
And if you don’t know if you should be concerned or not, you arent concerned. Go with one method.
Maybe that’s overly simplistic, but usually the goal is just to get the data into the database.