Listen To The Code

What does it mean to ListenToTheCode?

When a highly experienced and knowledgeable developer "listens to code" that has problems, they should find that the CodeSmells. (OK, so we mix metaphors here. ;-)

This doesn't describe the "process" or the "feeling" at all. What about good code? What does it really mean to be one with the code?

There are a few comments on "code listening" in CouldExtremeProgrammingHaveArisenWithoutSmalltalk and IsSmalltalkEasierToListenTo.


The code you have written to date should help you write more code today. If it doesn't help, if you feel like you have to overcome it rather than exploit it, then it smells bad. Code that smells bad generally has overly complicated or otherwise inappropriate abstractions.

Code can also be noisy. Noise in code can slow you down, but not in the same way as code that smells. The extra punctuation that most languages require counts as noise. Say you want to print HelloWorld. You might find the need to type a string of terminators after the last letter. It might look like this:

 !\n");}^D

That's noise. Lots of mindless comments or overly qualified names count as noise too. Noisy code isn't as bad as smelly code because we get used to the noise and ignore it. Smell doesn't go away so easily, in fact it will probably get worse.

The metaphors work because they productively relate to our sense of the real world. If our food smells then we should probably eat with caution because it may have gone bad. If our dining room is noisy we should probably ignore it, or consider moving to a quieter locale someday. -- WardCunningham


ListenToTheCode is one instance of a general success strategy involving the use of feedback. There should be no products produced which are not part of a feedback loop, and code is no exception. In particular, producers should be aware of the 'sound' and 'smell' of the code they produce. They should want to be aware of these things. --WaldenMathews


There should be no products produced which are not part of a feedback loop, and code is no exception.

Agreed. DouglasHofstadter theorizes (in the preface to the new edition of GoedelEscherBach) that consciousness arises from what he calls a tangled hierarchy, or strange loop. In other words, a system whose output feeds back into itself as input. Such a system is dynamic, living, and conscious. It's interconnected -- when one part of it evolves, the whole evolves with it. A conscious system will tell you what it needs to prosper if you listen. Based on my mental map of the system, I write code. The code determines the program's behavior, and the deviation of that behavior from the results I intended informs me where my map is off (and I adjust it). Energy flows from my internal map of the system, to the code, to the program's behavior, and back to my map. This process continues until the system reaches equilibrium. Then I add a new requirement (changing the map), and the cycle begins once again.

A process such as BigDesignUpFront cuts open this circuit -- the map is not allowed to change, and like anything organic that remains stagnant, it will acquire stuff growing on it and start to smell. -- JoshuaJuran Until you hear the comment "it smells like something died in here!"


But do try not to create an ExtremelySpoiledChild. --DaveWhipp


EditText of this page (last edited August 2, 2005) or FindPage with title or text search