Mozart Principle

Dr. Meinhold once said that good code is like Mozart symphony. If you add a single note or you take a single note, harmony is destroyed. If you add a single line of code or you take a single line of code, good code will break.

Hmm, you could add any number of lines without breaking the code. Unless you add them inside some string literals. ;-)


This is quite a good analogy, but not for the reason Dr Meinhold (who he?) apparently thought.

It might, I suppose, apply to very highly micro-optimized inner loops or deeply embedded code where every byte counts. In that sort of situation, you sometimes do need code that's wedged into a local optimum so that small changes will break it. But if much of your code is like that, you're either in an unusual niche or optimizing the wrong objective function.

And, similarly, the "small changes break it" property applies to some rather specialized kinds of music. If you're writing a two-page fugue then the task is very densely constrained, and again you probably can't make small changes without serious damage. But most music is not like this and, in particular, Mozart's symphonies don't include very much music like this.

You can make the same sort of analogy to other varieties of art. There are some short poems that could not be altered without damage. But there must be hundreds of places in, say, "Paradise Lost" where Milton could easily have changed two lines without hurting the poem.

So: Good code is like good music: mostly, there are plenty of incremental changes that don't hurt it much, but in some special and rare situations you need to write something ingenious and beautiful where incremental changes do break it.


Oh, how interesting. For me, the MozartPrinciple has always been the lesson that the MilosForman? film Amadeus attempted to hammer home : you can be an absolute genius at one thing - music in this case - and an absolute dolt in every other thing. We're still on topic, though, as the more general notion in psychology is called "modularity". ;) -- LaurentBossavit


Also see HumansSuck, SoftwareCrystal. Contrast with BigBallOfMud and JoelMosesOnAplAndLisp.


EditText of this page (last edited September 11, 2014) or FindPage with title or text search