Improve Code by Removing It
来源:互联网 发布:淘宝新开店铺流程 编辑:程序博客网 时间:2024/05/05 15:22
Improve Code by Removing It
Pete Goodliffe
Less is more. It’s a quite trite little maxim, but sometimes it really is true. One of the improvements I’ve made to our codebase over the last few weeks is
to remove chunks of it.
We’d written the software following XP tenets, including YAGNI (that is, You Aren’t Gonna Need It). Human nature being what it is, we inevitably fell short in a few places.
I observed that the product was taking too long to execute certain tasks— simple tasks that should have been near instantaneous. This was because they were overimplemented—festooned with extra bells and whistles that were not required, but at the time had seemed like a good idea.
So I’ve simplified the code, improved the product performance, and reduced the level of global code entropy simply by removing the offending features from the codebase. Helpfully, my unit tests tell me that I haven’t broken any- thing else during the operation.
A simple and thoroughly satisfying experience.
So why did the unnecessary code end up there in the first place? Why did one programmer feel the need to write extra code, and how did it get past review or the pairing process? Almost certainly something like:
78 97 Things Every Programmer Should Know

• It was a fun bit of extra stuff, and the programmer wanted to write it. (Hint: Write code because it adds value, not because it amuses you.)
• Someone thought that it might be needed in the future, so felt it was best to code it now. (Hint: That isn’t YAGNI. If you don’t need it right now, don’t write it right now.)
• It didn’t appear to be that big an “extra,” so it was easier to implement it rather than go back to the customer to see whether it was really required. (Hint: It always takes longer to write and to maintain extra code. And the customer is actually quite approachable. A small, extra bit of code snow- balls over time into a large piece of work that needs maintenance.)
• The programmer invented extra requirements that were neither docu- mented nor discussed in order to justify the extra feature. The requirement was actually bogus. (Hint: Programmers do not set system requirements; the customer does.)
What are you working on right now? Is it all needed?
- Improve Code by Removing It
- Improve Code by Removing It
- Improve code desige use Unity
- improve your python code(1)
- improve your python code(2)
- improve your python code(3)
- improve your python code(4)
- improve your python code(5)
- improve your python code(6)
- improve your python code(7)
- improve your python code(8)
- improve your python code(9)
- improve your python code(10)
- improve your python code(11)
- improve your python code(12)
- improve your python code(13)
- If this code works, it was written by Paul DiLascia.
- removing
- [5.18]编写一个学生和教师数据输入和显示程序,学生数据有编号、姓名、班号、和成绩,教师数据有编号 姓名、职称和部门。要求将编号、姓名输入和显示设计成一个类person,并作为学生数据操作类stud
- Java集合框架总结之Map集合的使用
- Sqrt(x)-LeetCode
- Qt 关于Qt5中QPrinter问题
- KVC的一些用法
- Improve Code by Removing It
- WPF 4.5 和C#(3.1)——布局(Stackpanel, Margin)
- Install Me
- 多线程抓取豆瓣编程书籍(linux\windows都可运行)
- Chromium主文档加载流程
- jQuery学习笔记
- Interprocess Communication Affects Application Response Time
- poj 3168 Treats for the Cows 区间dp
- Java集合框架六——泛型