This may be a subjective question, but I want to know what people feel, is this the best example of behavior of methods for saving or deleting objects?
When you set up a class that will contain information about the Db record, I usually declare the Delete () and Save () objects as void. Since these methods usually take a direct action on other properties of the object, do we need to return anything else to confirm the action? In the event of a failure, I simply let you handle the error processing the framework or implementation code, any exception.
I have seen many objects that send strings affected by int or other returns, what is an โexpertโ opinion on this?
i.e. this:
public void Delete()
{
if (this.objectID == null || this.objectID == -1) { throw new exNotDbObject() }
this.objectID = null;
this.TimeRetrievedFromDb = null;
}
vs this:
public int Delete()
{
if (this.objectID == null || this.objectID == -1) { throw new exNotDbObject() }
int retVal = dataLayer.DeleteObj(this.objectID);
return retVal;
}