Improve Code by Removing It

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?

时间: 2024-10-15 03:32:58

Improve Code by Removing It的相关文章

20 Best Code Review Tools for Developers

20 Best Code Review Tools for Developers Apr 02, 2015by vikas in TOOLS A programmer always faces the pressure of deadlines and with many delays the software which is designed is quite unstable and the whole product is unstable. The cause of this inst

Java Code Convention Rules

Rules available in this category: Avoid_subclassing_java_lang_Thread Always_declare_a_class_having_only_private_constructors_as_final Replace_enumeration_with_iterator Combine_if_statements_using_boolean_short_circuit_operator Avoid_using_fully_quali

PatentTips - Safe general purpose virtual machine computing system

BACKGROUND OF THE INVENTION The present invention relates to virtual machine implementations, and in particular to a safe general purpose virtual machine that generates optimized virtual machine computer programs that are executable in a general purp

JQuery Easy Ui dataGrid 数据表格

Extend from $.fn.panel.defaults. Override defaults with $.fn.datagrid.defaults. The datagrid displays data in a tabular format and offers rich support to select, sort, group and edit data. The datagrid has been designed to reduce development time and

Machine Learning for Developers

Machine Learning for Developers Most developers these days have heard of machine learning, but when trying to find an 'easy' way into this technique, most people find themselves getting scared off by the abstractness of the concept of Machine Learnin

Learning JavaScript Design Patterns -- A book by Addy Osmani

Learning JavaScript Design Patterns A book by Addy Osmani Volume 1.6.2 Tweet Copyright © Addy Osmani 2015. Learning JavaScript Design Patterns is released under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 unported license. It

转摘<<On becoming an expert C programmer>>

The following is from an EMail message that I sent to to an individual on 12-Apr-2001. You may find this EMail message useful. The Writer asked: ``I just recently visited your website ... Just wanted to say greetings and ask a simple question: Do you

在vi中使用perltidy格式化perl代码

格式优美的perl代码不但让人赏心悦目,并且能够方便阅读. perltidy的是sourceforge的一个小项目,在我们写完乱七八糟的代码后,他能像变魔术一样把代码整理得漂美丽亮,快来体验一下吧!!! perltidy 主页: http://perltidy.sourceforge.net/perltidy.html 安装方法: 进入解压后的文件夹,然后运行一下命令 perl Makefile.PL make make test make install 用法: 配置一下vim,使得我们在写代

Operating System Engineering

Operating System Engineering Course Meeting Times Lectures: 2 sessions / week, 1.5 hours / session Prerequisites 6.033 Computer System Engineering 6.170 Software Studio 6.004 Computation Structures Description 6.828 Operating System Engineering studi