class resultbean{ private method1result method1result; private method2result method2result; public void setmethod1result (Method1result method1result) { this.method1result = method1result; } public void setmethod2result (Method2Result Method2result) { this.method2result = method2result; }}class Test{ public Resultbean execute1 () { resultbean resultbean = new resultbean (); fillmethod1result (ResultBean); &nbSp;fillmethod2result (Resultbean); return resultbean; } public resultbean execute2 () { resultbean resultbean = new resultbean (); resultbean.setmethod1result (MakeMethod1Result ()); resultbean.setmethod2result (Makemethod2result ()); return resultBean; } public void fillmethod1result (Resultbean resultbean) { resultbean.setmethod1result (Method1result); } public void fillmethod2result (Resultbean resultbean) { &Nbsp; resultbean.setmethod2result (Method2result); } public method1result makemethod1result () { return method1Result; } public method2result makemethod2result () { return method2result; } }
In the code above, Execute1 and execute2 which coding habits better?
Personally think that the Execute2 method is a good habit, as we do things, the leader tells you to do one thing, it is hoped that you have a result feedback after completion, so it is suggested that some business methods in the actual coding if can abstract a result object, it is best to abstract out, so that increase the code readability, It can also achieve the effect of multiplexing.
Good coding habits-01