tomasp.net
Library patterns: Multiple levels of abstraction
Avoid callbacks. Callbacks are probably the easiest way of breaking composability. When you are writing some complex functionality (say, processing Markdown documentation), you might be tempted to parameterize some step using a callback (say, to plug-in a pre-processor that transforms document between parsing and rendering). The problem is that callbacks impose too much structure on your code. They do not give you the flexibility to put individual simpler pieces together in a different way. Instead, inserting callbacks makes the design more complicated than it was.