I am going over the Article class and have questions about the instance methods.
The Delete method:
Code:
public bool Delete()
{
bool success = Article.DeleteArticle(this.ID);
if (success)
this.ID = 0;
return success;
}
Why do we just set the ID property to zero and not reset all properties to their original values if the deletion is successful? Imagine that we have an Article object with all the information (holding the comments and everything) and we call the delete method. We would still have a lot of information in the object that is not really reflecting the record in the database. Is there a purpose for this?
The IncrementViewCount method:
Code:
public bool IncrementViewCount()
{
return Article.IncrementArticleViewCount(this.ID);
}
Why don't we update the object's ViewCount property? So we increment the ViewCount in the database by 1, but the property in the object is not reflecting that value. However, in the Approve method we do update the object's Approved property. This seems at least inconsistent.
The Rate method:
Code:
public bool Rate(int rating)
{
return Article.RateArticle(this.ID, rating);
}
Same thing as with the IncrementViewCount method. Why don't we update the TotalRating property?
Anyone else has found this awkward?
Thanks for any light on this.