The above code is kind of verbose and prone to bugginess in that if $params['id'] got messed with in-between the pre and post hook calls then the post hook might incorrectly be labelled 'edit' instead of 'create' or vice versa.
I'm sure you took this example from another file in CiviCRM but hey, I never said our existing code was perfect.
You'll find a better example here: CRM/Core?BAO/IM.php function add - compacts the above 12 lines into 3 :)