Divergent change (divergent)---signal to be reconstructed

Source: Internet
Author: User

When you look at a class that says, well, if you add a new database, I have to modify these three functions, and if there is a new financial instrument, I have to modify these four functions. Then, it might be better to divide the class into two, so that each object can be modified for just one change. The name of the above feature is called: Divergent change. It says that a class often changes in different directions for different reasons. For example, the above class, for two reasons, can cause this class to change in two different directions. We think that a class can only change for one reason, which is good. If, for a variety of reasons, this class changes, then we are going to refactor this class. Find out all the changes in this class for some reason, distill this part into a new class, use the Extract class technique, and then the new class will only cause changes for one reason. For example, the above class, because of two different reasons, in different directions change, then, can be refined one of the causes of changes in the relevant code, as a new class. For example, a new database is added, resulting in a change, and this part of the code is distilled into the new Class A.  In this way, the new class will only change for the reason of the database. Example: TBD.

Divergent change (divergent)---signal to be reconstructed

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.