I am focusing on something were a person can edit existing objects ("Filter" domain objects to become exact) via a GUI. Like a UI hint, we simply want to let the save button when the user really modified something towards the object. I'm wondering if anybody had any knowledge about this issue and what the easiest way is always to approach this.

I had been considering adding an isDirty() flag towards the domain object. Whenever a user begins editing a Filter, I'd make a duplicate, pass it towards the GUI and allow the user make changes towards the copy. A binding around the isDirty() flag would then enabled/disable the save button. On saving, the variations would then be merged in to the original object and endured.

Additionaly, I had been thinking an amount happen if your user undos the alterations he earned for an object. The isDirty() flag should then return false. And So I guess the only method to accomplish this would be to keep your original worth of each property within the domain object.

Any ideas?


Furthermore,you are able to expose two techniques: BeginEdit - Within this method, your mark your IsDirty Flag to True. Meaning you do modification. Refer to this as method when you're going to make changes

CancelEdit - Within this method, totally reset the IsDirty Flag to False. Meaning you've arborted the edit process and reverted to the initial condition. Refer to this as method when rescheduling any modifications made.

And when any modifications are endured, additionally you totally reset the IsDirty Flag to False.

I really hope this can help.

For those who have some objects that are being edited then you will most likely need something greater than a boolean flag for isDirty(). This issue isn't different to reference counting, i.e. increment a dirty rely on edit and decrement on undo. If you're supporting undo I suspect you will find yourself with a few pretty hairy logic. I'd ensure that it stays from your domain objects.

Yes, this is effective. Instead of undo, I personally use the IsDirty approach to signify that something May have transformed the record after which that creates my "did the record change logic". I developed my very own framework, where every table area is really a house of the object. Every time a area is written towards the objects "isDirty" flag is placed. Within the "SaveObject" approach to the item (really its a assistant class but tend to be easily within the object, however i wanted a chance to save objects in various manners, prefer to xml, database, ect.), I look into the IsDirty and when its false i quickly skip the save. This simplifies the logic as every time I'd the potential of altering the item, I call SaveObject and allow the framework handle it.

If you work with .Internet framework, you might want to have a look at CSLA .Internet framework by Rockford Lhotka: http://world wide web.lhotka.internet/cslanet/Default.aspx

CSLA is really a mature framework including object condition management (IsDirty), undo functionality, data binding and much more, and it also is free of charge and open-source.

Based on your domain, you could utilize equality to check for variations. Keep your original object making a copy from the object for editing. Anytime an edit might be carried out, customize the UI properly.

The advantage of this suggestion is it does not stick GUI specific functionality (the isDirty() flag) in your domain objects, but YMMV

If you're supporting operation undo at an amount of granularity more than 'undo everything since last save' then I'd suggest an undo stack. When something is edited, it (or it's undo operation functor or delegate) get's put into the stack. Whenever you undo, you just pop the stack and undo the operation sprang. Your isDirty() flag will be only a see if the undo stack consists of products, instead of extra storage and logic to update.