Code Fragment-删掉那些认为有用而注释掉的code。
来源:互联网 发布:数据库的设计步骤 编辑:程序博客网 时间:2024/06/05 01:19
本文思想参考自《Clean Code》
在android的源码里,有这样一段code。
// This is to replace p.setStyle(Style.STROKE); canvas.drawRect() since it // doesn't work well with hardware acceleration// private void drawEmptyRect(Canvas canvas, Rect r, int color) {// int linesIndex = 0;// mLines[linesIndex++] = r.left;// mLines[linesIndex++] = r.top;// mLines[linesIndex++] = r.right;// mLines[linesIndex++] = r.top;//// mLines[linesIndex++] = r.left;// mLines[linesIndex++] = r.bottom;// mLines[linesIndex++] = r.right;// mLines[linesIndex++] = r.bottom;//// mLines[linesIndex++] = r.left;// mLines[linesIndex++] = r.top;// mLines[linesIndex++] = r.left;// mLines[linesIndex++] = r.bottom;//// mLines[linesIndex++] = r.right;// mLines[linesIndex++] = r.top;// mLines[linesIndex++] = r.right;// mLines[linesIndex++] = r.bottom;// mPaint.setColor(color);// canvas.drawLines(mLines, 0, linesIndex, mPaint);// }
之前我也有过类似的行为,注释而不是删掉,常常有下面的原因:
- 这些code将来可能会用到。
而实际上:
- 这些code将来也不会用到。
- 这些code将来不能直接用,因为在注释掉的一段时间里,它本来的场景已经不合适。
- 这些code需要用到的时候,别人也不敢用,别人不知道你为什么注释掉,不清楚这些code现在有没有问题。
- 这些code常常没有用,但是非作者一般不会去删掉,这就会使注释掉的code越来越不适用。
- 即便这些code有用,完全可以通过代码控制工具恢复。
- Code Fragment-删掉那些认为有用而注释掉的code。
- Code Fragment-有趣的注释
- 有用的Code
- Code Fragment~~
- 有用的SAP Basis T-CODE
- 有用的SAP Basis T-CODE
- Code Fragment-一些工具类的特点
- Code Fragment-定义合适的数据结构。
- Code Fragment-封装重复代码的代码
- 注释你的代码 Commenting your code
- "注释"的注意事项--《Clean Code》笔记
- 关于Code Review的那些事
- quake3 code fragment [1]
- code fragment One from
- code fragment Two from
- code fragment Three from
- code fragment Four from
- code fragment Five from
- 堆栈段
- jsp自定义标签
- 理解javaScript闭包
- Cuda实现Radon变换
- Qt版本-塔防游戏实现三
- Code Fragment-删掉那些认为有用而注释掉的code。
- 60个开发者不容错过的免费资源库
- windows下配置nginx+php环境
- POJ 1041 - John's trip 输出欧拉回路路径边..通用做法
- 编程基础理论题汇总
- 设计模式在C语言中的应用--读nginx源码
- b3log版的反射ReflectHelper
- onSaveInstanceState和onRestoreInstanceState触发的时机
- C++ FAQ学习笔记 9,10章