Dealing with bad code is a daily reality for some developers. Here are some of the best—and worst—approaches to take.