Project on the basis of existing code development, but encountered a lot of egg pain code. For example, here's a look at how many slots you can find:
1 Public StaticString Adddate (string date, string into)throwsException2 {3String sdate = "";4 Try5 {6Date = Date.replaceall ("-", "/");7Date = date.substring (0, Date.length ()-2);8GregorianCalendar GRC =NewGregorianCalendar ();9Grc.settime (NewDate (date));Ten Grc.add (Gregoriancalendar.date, Integer.parseint (into)); OneSimpleDateFormat formatter =NewSimpleDateFormat ("Yyyy-mm-dd"); ASdate =NewString (Formatter.format (Grc.gettime ())); - } - Catch(Exception e) the { - Throwe; - } - returnsdate; +}
1. Catch exception and throw away, Adddate would have to throw exception,try purely superfluous
2. The sdate variable is purely superfluous
3. Formatter.format would have returned a string, and a new string, a purely superfluous
Look at the Java code that hurts.