Interim variables & in replacement of temporary variables

xiaoxiao2021-03-06  103

Inline Temp (Inline) and Replace Temp with Query (instead of a temporary variable)

Inline Temp:

Summary:

You have a temporary variable that is only assigned a simple expression, and it hinders other reconstruction methods.

TIPS:

Inline Temp is mostly used as part of Replace Temp with Query. This type of temporary variable must only be assigned once.

Replace Temp with Query:

Summary:

Your program saves an interpretation result of a certain expression with a temporary variable.

TIPS:

These temporary variables are only visible in the function and are only used for the function. Replace Temp with Query provides practical premise for the extract method partial variables. Like the interim variables of Inline Temp, such variables must also be assigned once. If the temporary variable saves accumulation information from the loop, the loop is relatively simple, you can extract the temporary variable with the cyclic body into a separate query.

Comments by Allen Lee:

When using Replace Temp with Query, if the refined variable (sometimes add some extra verification or query code) is only visible to the Class, it can be refined into a private function, if these trophy refined temporary variables You need to rely on other data, you can try to pass these data in the form of parameters, which is the overload function. If the query that does not require incoming parameters will be disclosed in the future, it is possible to retain the Query in the form of the function, and the Query of the function can be further publicly disclosed. If Query has an overload function, the preserved function will have a better effect, otherwise the Query in the Property form will be the code more intuitive. C # 2.0 Property will provide the functionality of setter and getter different Accessibility, so you can be the Query to read only, but you can read it.

转载请注明原文地址:https://www.9cbs.com/read-104393.html

New Post(0)