Saturday, November 18, 2006

Smart Update Summary (3)

Status

After update() method changes the status of all information structures, smartUpdateAllOfBlocks() changes DB by checking these status. How to change DB is decided by the status.

smartUpdateBlock_kindsofstatus

Loaded

This information structure is loaded. And, the information and another information of the latest collection are not different. Therefore, we don't need to change DB about this information.

Updated

This information structure and another information are different. And, the information has been updated with another information. Therefore, we should update a record of DB about the information. updateBlockByInfo() is a good utility method for that.

Order Updated

This information structure and another information are the same content. But, only their orders are different. Therefore, we should update a order field of a record of DB about the information. Well, blocks don't have the order information. This status assigns to preferences only.

New

When the current collection doesn't have a information, it is added to the current colletion. And, the status of the information is changed to 'New'. In this case, we have to insert it to DB. insertBlockByInfo() is a good utility method for that.

Deleted

Since this information structure was not found in the latest collection, the status of the information has been changed to 'deleted'. In this case, we have to delete it from DB. uinstallBlockByInfo() is a good utility method for that.

Conclusion

smartUpdateAllOfBlocks() and smartUpdateAllOfPreferences() are very useful, because they can implement enough process which I have explained these days. In most cases, you may leave updating to these utility methods. But, if you need advanced updating in your phased upgrade, you should understand these classes.

No comments: