当前位置:网站首页>记录开发问题
记录开发问题
2022-07-28 15:58:00 【从一而终】
场景:
写代码中遇到一个问题:比如我们需要做一个登陆操作,然后在这个登陆操作之前要进行几次确认交互,几次交互都必须保证成功,我写的代码结构如下
bool step1();
bool step2();
bool step3();
bool step4();
bool step5();
bool step6();
bool login()
{
ret = step1();
if(!ret)
{
return ret;
}
ret = step2();
if(!ret)
{
return ret;
}
ret = step3();
if(!ret)
{
return ret;
}
ret = step4();
if(!ret)
{
return ret;
}
ret = step5();
if(!ret)
{
return ret;
}
ret = step6();
if(!ret)
{
return ret;
}
return true;
}这个代码结构让人看起来比较恶心,怎么优化?
bool step1();
bool step2();
bool step3();
bool step4();
bool step5();
bool step6();
bool login()
{
ret1 = step1();
ret2 = step2();
ret3 = step3();
ret4 = step4();
ret5 = step5();
ret6 = step6();
return ret1 & ret2 & ret3 & ret4 & ret5 & ret6;
}这个优化可以吗? 表示疑问
边栏推荐
- Leetcode daily practice - the number of digits in the offer 56 array of the sword finger
- 关于MIT6.828_HW9_barriers xv6 homework9的一些问题
- 微软100题-天天做-第16题
- Quickly master kotlin set functions
- 队列的介绍与实现(详解)
- Early in the morning, pay Bora SMS to say that you won the "prize"? Dealing with server mining virus - kthreaddi
- Qt学习之Qt Designer(设计师)
- Signal and slot mechanism of QT learning
- WSL+Valgrind+Clion
- Interesting kotlin 0x07:composition
猜你喜欢

HM secondary development - data names and its use

Introduction and implementation of stack (detailed explanation)

Configure HyperMesh secondary development environment on vs Code

Ansa secondary development - build ansa secondary development environment on Visual Studio code

HyperMesh auto save (enhanced) plug-in instructions

LeetCode-学会对无序链表进行插入排序(详解)

HyperMesh自动保存(增强版)插件使用说明

Sort 1-insert sort and Hill sort

学会使用MySQL的Explain执行计划,SQL性能调优从此不再困难

阿里大哥教你如何正确认识关于标准IO缓冲区的问题
随机推荐
“蔚来杯“2022牛客暑期多校训练营3 J.Journey 0-1最短路
Ansa secondary development - build ansa secondary development environment on Visual Studio code
Applet: get element node information
Installation of QT learning
微软100题-天天做-第11题
局域网无法访问apache服务器
MySQL5.7及SQLyogV12安装及使用破解及常用命令
Li Hongyi, machine learning 5. Tips for neural network design
HM二次开发 - Data Names及其使用
Each account corresponds to all passwords, and then each password corresponds to all accounts. How to write the brute force cracking code
Abaqus GUI界面解决中文乱码问题(插件中文乱码也适用)
2021-04-02
IM即时通讯开发优化提升连接成功率、速度等
“蔚来杯“2022牛客暑期多校训练营3 ACFHJ
Qt学习之信号和槽机制
Best Cow Fences 题解
Qt学习之Qt Designer(设计师)
Introduction and implementation of stack (detailed explanation)
有趣的 Kotlin 0x0A:Fun with composition
排序3-选择排序与归并排序(递归实现+非递归实现)