Code fragment-put similar functions together

Source: Internet
Author: User

The following code is provided in packages/apps/phone/src/COM/Android/phone/gsmumtscallforwardoptions. Java of Android source.

Package COM. android. phone; // some codes are omitted: public class extends {// some codes are omitted: Private Static final string button_cfu_key = "button_cfu_key"; Private Static final string button_cfb_key = "button_cfb_key "; private Static final string button_cfnry_key = "button_cfnry_key"; Private Static final string button_cfnrc_key = "button_cfnrc_key"; private callforwa Rdeditpreference mbuttoncfu; // note1: the declared order private parameter mbuttoncfb; private parameter mbuttoncfnry; private parameter mbuttoncfnrc; @ override protected void oncreate (bundle icicle) {super. oncreate (icicle); // omitting some code mbuttoncfu = (callforwardeditpreference) prefset. findpreference (button_cfu_key); // note2: Stick to the previous order. Mbuttoncfb = (callforwardeditpreference) prefset. findpreference (button_cfb_key); mbuttoncfnry = (callforwardeditpreference) prefset. findpreference (button_cfnry_key); mbuttoncfnrc = (callforwardeditpreference) prefset. findpreference (button_cfnrc_key); mbuttoncfu. setparentactivity (this, mbuttoncfu. reason); // note3: Put the same processing together to form a strong analogy mbuttoncfb. setparentactivity (this, mbuttoncfb. reason); // separate different processing blocks. Mbuttoncfnry. setparentactivity (this, mbuttoncfnry. reason); mbuttoncfnrc. setparentactivity (this, mbuttoncfnrc. reason); mpreferences. add (mbuttoncfu); mpreferences. add (mbuttoncfb); mpreferences. add (mbuttoncfnry); mpreferences. add (mbuttoncfnrc);} // some code is omitted}

The Code has the following features:

  • There is a certain declaration order during the declaration.
  • This order is adhered to during use.
  • Put the same processing together to highlight Functional consistency.
  • Different Processing Sections are separated, indicating that the logic is different. (In some scenarios, it can represent a sequential relationship)

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.