I have a large family of objects, all of which come from a single parent. Objects all know how to determine if they have been changed, but I also need to find out if a new instance of the object has been changed from the one I already have in memory (testing to check if someone else has updated the database and the object was edited.)
As a result, each child class must contain the same method:
public new bool Changed()
{
return Changed(this);
}
This really works in my craw, but I do not see the path around it, since the real work must be done by a function that takes a parameter of the same type as the class that it is in - so it cannot be virtual. (Of course, I could define it to take the parent and drop it every time, but the comparison function accepts any object in the tree, not just the right one, and it requires a security code in each instance, again something ugly.)
Of course this works, but I don't like the ugly code.
Update. As for the function Changed, each object saves a copy of its state at boot time.
source
share