重构26-Remove Double Negative(去掉双重否定)
public class Order {public void Checkout(List<Product> products, Customer customer) {if (!customer.getNotFlagged()) {// the customer account is flagged // log some errors and return return; }// normal order processing }}public class Customer {public Double Balance; public Boolean IsNotFlagged; public Boolean getNotFlagged() {return Balance < 30d; }public void setNotFlagged(Boolean notFlagged) {IsNotFlagged = notFlagged; }}
public class Order {public void Checkout(List<Product> products, Customer customer) {if (customer.getFlagged()) {// the customer account is flagged // log some errors and return return; }// normal order processing }}public class Customer {public Double Balance; public Boolean IsFlagged; public Boolean getFlagged() {return Balance < 30d; }public void setFlagged(Boolean Flagged) {IsFlagged = Flagged; }}
转载于:https://www.cnblogs.com/jgig11/p/5786447.html
重构26-Remove Double Negative(去掉双重否定)相关推荐
- Remove Double Negative(去除双重否定)
WHAT 双重否定的条件语句,可以使用一个肯定的条件语句代替 记住:双重否定 = 肯定 本次重构涉及到的基本重构手法: Extract Method(提炼方法) Inline Method(内联方法) ...
- 重构第26天 移除双重否定(Remove Double Negative)
理解:"移除双重否定"是指把代码中的双重否定语句修改成简单的肯定语句,这样即让代码可读,同时也给维护带来了方便. 详解:避免双重否定重构本身非常容易实现,但我们却在太多的代码中见过 ...
- LeetCode 26 Remove Duplicates from Sorted Array [Array/std::distance/std::unique] c++
LeetCode 26 Remove Duplicates from Sorted Array [Array/std::distance/std::unique] <c++> 给出排序好的 ...
- 26. Remove Duplicates from Sorted Array【easy】
26. Remove Duplicates from Sorted Array[easy] Given a sorted array, remove the duplicates in place s ...
- Leet Code OJ 26. Remove Duplicates from Sorted Array [Difficulty: Easy]
题目: Given a sorted array, remove the duplicates in place such that each element appear only once and ...
- LeetCode 26. Remove Duplicates from Sorted Array
题目: Given a sorted array, remove the duplicates in place such that each element appear only once and ...
- leetcode 283 Move Zeros; 27 Remove Elements; 26 Remove Duplicated from Sorted Array;
int arr[] = {0,1,0,3,12}; //把数组的值赋给vector vector<int> vec(arr, arr+sizeof(arr)/sizeof(int)); 解 ...
- leetcode python3 简单题26. Remove Duplicates from Sorted Array
1.编辑器 我使用的是win10+vscode+leetcode+python3 环境配置参见我的博客: 链接 2.第二十六题 (1)题目 英文: Given a sorted array nums, ...
- leetCode #26 Remove Duplicates from Sorted Array
删除相同数字 1 class Solution { 2 public: 3 int removeDuplicates(vector<int>& nums) { 4 int coun ...
最新文章
- 元学习—Meta Learning的兴起
- ORA-09817:Write to audit file failed
- 二、使用rails3.0自带的数据检查功能检查输入数据
- 机器学习手动撸代码系列3-感知机
- dotnet watch+vs code提升asp.net core开发效率
- 你胆敢不加break试试?
- *【51nod - 1459】迷宫游戏(记录双向权值的Dijkstra单源最短路)
- android自动布局优先级,自动布局AutoLayout
- lambdapython语法_Python中lambda表达式的语法与应用
- TWaver初学实战——基于HTML5的交互式地铁图
- 不会Netty,你也永远不会熟悉Java
- 好用的jquery.animateNumber.js数字动画插件
- Qt实现提示音以及QSound的使用说明
- 单片机查表实验c语言,单片机 查表程序设计实验
- png文件格式详解【转】
- PDF是如何在线分割的?
- python if else语句例子,python 中if else 语句的作用及示例代码
- 缓冲区溢出漏洞_缓冲区溢出漏洞简介
- MA、WMA、EMA、EXPMA区别及公式详述
- 从多个pdf文档中截取部分区域拼接成一个pdf文档