如何写出让同事无法维护的代码 - 李云鹏 #DevFest2021#【CC字幕】

演讲者背景:https://dsj.imut.edu.cn/info/1053/3884.htm
https://book.douban.com/subject/2208597/

《测试驱动开发》
温伯格《理解专业程序员》
Roedy Green How to write unmaintainable code
https://www.spigotmc.org/threads/how-to-write-unmaintainable-code-roedy-green.117330/
https://hilton.org.uk/blog/how-to-write-unmaintainable-code
陈皓:如何写出无法维护的代码
https://coolshell.cn/articles/4758.html



没有尾探,导致箭头式代码
争议:阅读困难,编写省力(少return)
IDEA Alt+ Enter 可以自动重构,添加return

函数嵌套、对象嵌套 一层又一层

避免上级干扰,坚持正确的设计
“在引起问题的框架内思考,将永远无法解决问题。”
model - view - controller
MVC 的初衷
- 提高模块复用程度
- 提高可读性
- 提高可测试性
model - view - presenter
diff MVP MVC区别:
The Controller works as the entry point, but in MVP, the entry point is View.
https://askanydifference.com/difference-between-mvc-and-mvp
业务快速发展,代码快速累积
重构不算绩效,没有动力
单项依赖,重构成本低

基于MVP,增加了 “统筹层”


1~2个 if-else block
use case 单元测试
谷歌蓝图构建系统
https://github.com/google/blueprint
MVC适用Java后端服务
Android开发种,MVC已经不流行