In Magento Observer catch Magento events and run your function after that event. Magento events like checkout_cart_product_add_after,checkout_cart_save_after etc you can get more Magento events from Magento Events Cheat Sheet (1.7.0.0)
This way of adding custom event before and after save is useful when we just need to add or do something before or after any Magento core event. For example, setting some values to some attributes before or after product is saved.