当前位置:网站首页>Inline temporary variables of code refactoring to replace temporary variables with queries
Inline temporary variables of code refactoring to replace temporary variables with queries
2022-04-22 02:43:00 【Programming Capriccio】
Intention - Make this information available to all functions in the same class , Be able to write clearer code for this class
Example
/**
* Before replacing temporary variables with queries
* Created by luo on 2017/4/19.
*/
public class ReplaceTempWithQueryBefore {
private double _quantity;
private double _itemPrice;
public double test() {
double basePrice = _quantity * _itemPrice;
if (basePrice > 1000) {
return basePrice * 0.95;
} else {
return basePrice * 0.98;
}
}
}
/**
* After replacing temporary variables with queries
* Created by luo on 2017/4/19.
*/
public class ReplaceTempWithQueryAfter {
private double _quantity;
private double _itemPrice;
public double test() {
if (basePrice() > 1000) {
return basePrice() * 0.95;
} else {
return basePrice() * 0.98;
}
}
private double basePrice() {
return _quantity * _itemPrice;
}
}
版权声明
本文为[Programming Capriccio]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211408404005.html
边栏推荐
- Can you really use ` timescale?
- Dump mangodb data using Navicat
- 【※ LeetCode 剑指 Offer 13. 机器人的运动范围(简单)】
- MySQL Chapter 1 Introduction to database
- PV-TSM原理及matlab仿真
- Friends don't see how to add, write it down first.
- Eight common probability distribution formulas and visualization
- Create a two-way linked list (detailed explanation)
- Digital twin tank warfare, technology promotes battlefield information digitization
- centos7安装mysql5.7的详细教程
猜你喜欢

Application and principle analysis of ThreadLocal

离散数学(Closure operation)闭包运算全解

刷题计划——动态规划dynamic programming(二)
![[Xiao Yang takes you to play with C language] circular structure (detailed explanation)](/img/78/407cfec7557c42bc66e55360436605.png)
[Xiao Yang takes you to play with C language] circular structure (detailed explanation)

STM32 FLASH操作

【※ LeetCode 劍指 Offer 12. 矩陣中的路徑(簡單)】

Problem brushing plan -- dynamic programming (II)

Financial information security training - 22 / 4 / 19 (Part I)

Alibaba P9 explains high concurrency in detail, and shows you how Taobao can resist large-scale second kill activities such as double 11

Training set: alexnet classification
随机推荐
Digital twin tank warfare, technology promotes battlefield information digitization
【小杨带你玩转C语言】循环结构(详解篇)
Go use options mode to set parameters
IIS提示:“此网站要求您登录”的解决办法。
金融信息安全實訓——22/4/19(上)
Excel tips - vlookup automatic matching
二元交叉熵损失函数
使用navicat将mangodb的数据做转储
How does ECS connect to ad domain or LDAP user source
DOS 命令行基本命令及实践
Why is the country established
Who has the at instruction set of CDMA mobile phone? Even the strange problems encountered by the computer. [email protected]
To civilized lifestyle and environmental pollution
Analysis of five data structures of redis
Pv-tsm principle and MATLAB simulation
SED and awk tools of shell
[TIANTI competition] l2-040 Zhezhi game (25 points (s)) (simulation)
(进阶用法) C语言字符串函数
【时序】DCRNN:结合扩散卷积和GNN的用于交通流量预测的时空预测网络
Binary cross entropy loss function