Reconstruction Method 42: Rename method (renamed function)

Source: Internet
Author: User

 

The function name does not reveal the function's purpose.Modify the function name.

Motivation: A strongly advocated programming style is to break down complicated processing into small functions. However, if you do not do well, this will make you fail to understand the respective uses of these small functions. To avoid this problem, the key is to give a good name to the function. The function name should accurately express its purpose. There is a good way to name a function: first consider the comments that should be written to the function, and then try to convert the comments into the function name.

You often cannot name a function for the first time. If you see that a function name cannot express its purpose, you should modify it immediately. YourCodeFirst, it is written for humans, and second, it is written for computers. A function with a good name is required. If you give each function a good name, you may save a lot of time. It is not easy to start a good name and requires experience. To become a real programmer, the level of name is crucial. Of course, other parts of the function signature are equally important. If you reschedule the Parameter order to help improve the definition of the code, you can do it boldly. There are also the Add parameter and remove parameter weapons.

Method: 1. Check whether the function signature has been implemented by a superclass or subclass. If yes, perform the following steps for each instance.

2Declare a new function and name it the new name you want. Complicate the code of the old function into the new function and make appropriate adjustments.

3, Compile.

4Modify the old function to forward the call to the new function.

5, Compilation, and testing.

6Find all the reference points of the old functions, modify them, and make them modify and reference the new functions. Compile and test each modification.

7And delete old functions.

8, Compilation, and testing.

 

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: info-contact@alibabacloud.com 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.