When working on any electrical component on the vehicle, it is always a good idea to disconnect the negative (-) battery cable. This will prevent potential damage to many sensitive electrical components such as the Engine Control Module (ECM), radio, alternator, etc.
Any time you disengage the battery cables, it is recommended that you disconnect the negative (-) battery cable first. This will prevent your accidentally grounding the positive (+) terminal to the body of the vehicle when disconnecting it, thereby preventing damage to the above mentioned components.
Before you disconnect the cable(s), first turn the ignition to the OFF position. This will prevent a draw on the battery which could cause arcing (electricity trying to ground itself to the body of a vehicle, just like a spark plug jumping the gap) and, of course, damaging some components such as the alternator diodes.
When the battery cable(s) are reconnected (negative cable last), be sure to check that your lights, windshield wipers and other electrically operated safety components are all working correctly. If your vehicle contains an Electronically Tuned Radio (ETR), don't forget to also reset your radio stations. Ditto for the clock.