当前位置:网站首页>记录开发问题
记录开发问题
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;
}这个优化可以吗? 表示疑问
边栏推荐
- NoSQL introduction practice notes I
- 快速掌握 Kotlin 集合函数
- 小程序:scroll-view默认滑倒最下面
- Implementation of transfer business
- mysql cdc 如果binlog日志文件不全,全量阶段能读到所有数据吗
- CRC16数据校验支持ModelBus和XMODEM校验模式(C语言)
- Oracle system composition
- Mysql与Oracle的13点区别
- Qt学习第一天
- Leetcode daily practice - the number of digits in the offer 56 array of the sword finger
猜你喜欢
随机推荐
Splash (rendering JS service) introduction installation
遭MQ连连干翻后的醒悟!含恨码出这份MQ手册助力秋招之旅
每一个账号对应所有密码,再每一个密码对应所有账号暴力破解代码怎么写?...
Qt学习第一天
Debugging methods of USB products (fx3, ccg3pa)
Microsoft question 100 - do it every day - question 11
Kubeedge releases white paper on cloud native edge computing threat model and security protection technology
Wake up after being repeatedly upset by MQ! Hate code out this MQ manual to help the journey of autumn recruitment
NoSQL introduction practice notes I
局域网无法访问apache服务器
Some suggestions on optimizing HyperMesh script performance
Installation of QT learning
WSL+Valgrind+Clion
Sort 5-count sort
Implementation of paging
关于MIT6.828_HW9_barriers xv6 homework9的一些问题
PHP gets the applet code, and the applet jumps with parameters
关于 CMS 垃圾回收器,你真的懂了吗?
Mysql与Oracle的13点区别
ANSA二次开发 - Visual Studio Code上搭建ANSA二次开发环境









