Rebuild 5th days: extract method objects and refactor 5th days

Source: Internet
Author: User

Rebuild 5th days: extract method objects and refactor 5th days
Rebuild 5th days: Extract Method object

In a class, when we have a long method, we usually use the extraction method to refactor, but sometimes, this method causes multiple local variables in a method body. In this case, we 'd better use the method object extraction method for reconstruction.

Place the method in another separate class and change the local variable to the field of the class.

Class Order... double price () {double primaryBasePrice; double secondaryBasePrice; double tertiaryBasePrice; // long computation ;...}

What are the specific methods for extracting object-oriented remote sensing information? 1) determine the problem domain, including defining the domain, selecting the domain, and refining and adding the domain as needed;
(2) Partition classification and objects, including defining objects, defining classes, and naming;
(3) differentiate the entire object and its components, and determine the relationship and structure of the class;
(4) define attributes, including determining attributes and arranging attributes;
(5) define services, including determining the object status, determining the required services, and determining message connections;
(6) determine the additional system constraints.
What objects are suitable for sketch deconstruct (namely, parsing, reconstruction, structural sketch, element extraction, amplification analysis, and final reorganization), such as onions, cabbage, and so on. The internal structure is clearer!

Related Article

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.