The Artima Developer Community
Sponsored Link

Flexibility and Complexity
A Conversation with Martin Fowler, Part IV
by Bill Venners
November 25, 2002

<<  Page 3 of 4  >>

Advertisement

Criteria for a Simple System

Bill Venners: In Refactoring, you quote Kent Beck's four criteria for a simple system: 1) Runs all the tests. 2) Reveals all the intention. 3) No duplication. 4) Fewest number of classes or methods. What is simplicity to you?

Martin Fowler: I think it is difficult to come up with a definition of simplicity. I quite like Kent's four rules. The first one reminds us that we have to run all the tests.

Bill Venners: But what does that have to do with simplicity? I could have something very complicated that runs all its tests.

Martin Fowler: Yes, but to have a well designed system it's got to work. If you remove the constraint that my system actually got to work...

Bill Venners: Oh, you're saying running the tests is necessary but not sufficient.

Martin Fowler: Exactly. Once the tests run you ask yourself, did you remove all the duplication? The third criteria, reveals all the intention, is the really hard part, because it is very subjective. You should be able to read the code and see what it does. The design intent of the code should just be apparent as you look at the code. A simple example is a well-named method. Rather than naming a method x74-3, and then providing a comment that says what the method does, why don't you just say what the method does in the name? That's more intention revealing. Ask yourself, does the structure of your code, the way the code is named, etc., really reveal the intention of your code?

Once all of that is out of the way, you obviously don't want more lines of code than you need. Only at the end do you minimize the number of classes and methods—only once all the other criteria are true. It is more debatable which order to apply the second and third criteria, reveals all the intention and has no duplication. But running the tests has to be the number one thing, and the minimum amount of code criteria should be the last thing.

<<  Page 3 of 4  >>


Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us