Web This site

Tuesday, December 13, 2005

Simplicity, comments and refactoring

David Crow posts an article about Simplicity Rules. I like number 10:

Simplicity is about subtracting the obvious, while adding the meaningful

It reminds me of removing obvious comments from code and refactoring code to make it meaningful and self-documenting.

Here are Kent Beck's criteria for evaluating the simplicity:


  1. Appropriate for the intended audience: No matter how elegant a solution is, if the people who need to work with it don't understand it, it isn't simple for them. Do the simplest thing that works for the audience.

  2. Communicative: Every idea that needs to be communicated should be represented in the solution. The code should express the programmer's intentions and should communicate to the readers.

  3. Factored: Do something once and only once. There should be no duplication. Duplication of logic or structure makes code hard to understand and modify.

  4. Minimal: Working within the above 3 constraints, the solution should have the fewest elements possible. If you ain't gonna need it [YAGNI], don't do it. Fewer elements means less to test, document, and communicate.

Tags:

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home