First make certain the ignition switch is in the off position. This will avoid the electrical an surge from being created in components like the ignition coil, air conditioner clutch, solenoids and relays. This electrical surge can cause damage to engine control computers, radios and other electrical components. As long as the ignition switch is off, damage can't occur.
Next, always disconnect the negative or ground cable first. Since the negative cable is connected to the vehicle body , if your wrench touches the vehicle no spark or voltage surge will occur. You should isolate the negative cable. If you have an air bag you MUST isolate the negative cable. Simply wrap the metal part of the battery cable with electrical tape. A section of an old bicycle inter tube can be cut and used the cover the terminals. After the negative cable is isolated, disconnect the positive cable. If you have an air bag system, you should isolate the positive cable too.
Always clean the terminals and terminal ends before re-connecting to the battery. Attach the connectors exactly as they were before. Start with the positive cable. Do not over tighten the cables, you only want a good electrical connection. Install the negative cable last, make certain that the ignition switch is off and the lights and accessories turned off too. Finish the job by applying corrosion preventative (or petroleum jelly) to the cables, terminals and hold down bolts.