views:

236

answers:

7

Robert C. Martin offers in the fist chapter of his book 'Clean Code' several definitions of 'clean code' from differen well known software experts. How do you define clean code?

A: 

Code in which the different modules or classes have clearly defined contracts, is a good start.

gnud
+7  A: 

Code I'm not afraid to modify.

g andrieu
+10  A: 
  • Easy to understand.
  • Easy to modify.
  • Easy to test.
  • Works correctly (Kent Beck's suggestion - very right).

These are the things that are important to me.

Ree
It should also work correctly. Otherwise this seems like a fine definition to me.
Kent Beck
Good point, I added it to the answer.
Ree
A: 

Code which doesn't break in multiple places when you make a single, seemingly insignificant change. It is also easy to follow the control path of the program.

Jesse
+3  A: 

Code that doesn't require any comments to be easily understood.

Jonathan van de Veen
A: 

Point-free Haskell code. (Not really, though.)

Deniz Dogan
+1  A: 

Code which reads as close to a human language as possible. I mean it on all the levels: from syntax used, naming convention and alignment all the way to algorithms used, quality of comments and complexity of distribution of code between modules.

Simplest example for naming convention:

if (filename.contains("blah"))

versus

if (S_OK == strFN.find(0, "blah"))

Part of it depends on the environment/APIs used, but most of it is of course the responsibility of the developer

Rom