请赐教:Java:代码重构/优化
您更喜欢哪一个?为什么? [可读性?记忆关注?其他一些问题?]
String strSomething1 = someObject.getSomeProperties1();
strSomething1 = doSomeValidation(strSomething1);
String strSomething2 = someObject.getSomeProperties2();
strSomething2 = doSomeValidation(strSomething2);
String strSomeResult = strSomething1 + strSomething2;
someObject.setSomeProperties(strSomeResult);
2.
someObject.setSomeProperties(doSomeValidation(someObject.getSomeProperties1()) +
doSomeValidation(someObject.getSomeProperties2()));
如果你会做一些其他的方式,那会是什么呢?你为什么要那样做?
当然是一个例子..我删除它,因为你可能会想为什么我的版本.. :) – DragonBorn 2008-11-25 15:29:08