Good coding habits-01

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.