Bad code: 07: feature envy)

Source: Internet
Author: User
Tags types of functions

A function is more interested in a class than in its own class. The common focus is data. A function calls almost half a dozen value functions from another object to calculate a value. In this case, an applicationMove Method(Shift function)Move it to the desired place. Sometimes only a part of functions suffer from this attachment.Extract Method(Extract function) extract this part into the independent function, and then useMove Method(The moving function) takes it to its dream home.

A function usually uses several types of functions. Where should it be set? Principle: Determine which class has the data most used by this function, and then put this function and that data together. If you useExtract Method(Extraction function)The above steps are easy to complete by decomposing this function into several smaller functions and placing them in different locations.

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.