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.
Anytime the battery cables have been disconnected and then reconnected, some abnormal drive symptoms could occur. The is due to the ECM losing the memory voltage and its learned adaptive strategy. The vehicle will need to be driven for 10 miles (16 km) or more until the ECM relearns its adaptive strategy, and acclimates the engine and transmission functions to your driving style.