Functional design patterns and cargo cult blogging

Again, I've found someone. I considered stopping last time. But this one is too good. I will only pick some parts of the post, there is not enough time to fight all stupidity there is in the world - I need to choose my battles. As the last two posts, I've again chosen someone who rants and has an aggressive and insulting tone without any knowledge of the matter the writes about.

Let's start. Don't get fooled by the beginning of his post:

"At the same time, I actually think I'm a fairly good programmer. I also think I have a fairly good understanding of what most of these buzzwords actually mean [...]"

As well see shortly, contrary to his introduction he has absolutely no clue what he's writing about. The first subject of his lengthy rant are design patterns:

"What is so wonderful about design patterns? Some of them are known to be goddamn awful constructs that will only pollute your codebase. What a design pattern really is, is a makeshift solution to a shortcoming in your language. A proper language would make every single design pattern redundant."

He's glorifying functional programming later. Do only I find it funny that people ranting against design pattern (the OO ones) don't see that currying and monads are FP design patterns? Design patterns are best practices for designing software solutions and have nothing to do with OO.

Design patterns in OO languages and Java in particular, are not part of the language. They form a solution to common problems on top of the language. The state monad, the monte carlo monad, backtracking monads, maybe and either monads. All solve problems outside the functional domain of the language. (One could argue currying is not a design pattern but an implementation pattern. Go read the Beck book.)

Simple minded people everywhere. Who can't see the wood for the trees. This seems prevalent in the functional community - at least the people who blog. If you want to read something about functional programming that is insightful read something from apocalisp. And use OCaml or Scala, or sneak good ideas into your Java code with functional Java.

"What is a design pattern? Code duplication? It's a recipe for writing the same code over and over. And we all know that this is bad. You shouldn't have duplicate code."

The poster has no clue what a design pattern is. He quotes the Visitor pattern himself. The Visitor pattern is a clever way to use handlers with double dispatch and polymorphism. There is no duplication:

public void visit(Customer customer) {
  // do something with customer

And though other languages don't need the visitor pattern - Nice with multimethods for example - they essentially do the same thing:

handle(Customer customer) 
  // do something with customer

The solution is the same. Those languages have internalized the constructs and have syntactic sugar for less boilerplate. They don't have new concepts. The concepts are the same.

This is how he describes a Factory

"An object that wraps a function that you can tailor to construct and return an object so you don't have to construct it completely from scratch when you need it."

Thats more of a Prototype or Singleton pattern. Factory is a different solution to a different problem.

This makes me sound like a design pattern evangelist. But though I've learned a lot about programming from design patterns, I rarely use them. Mostly not because they are bad, but there are myriads of other problems to solve - which can't be solved by common Design Patterns (yet?).

That said, some should be used more often, NullObject especially. And some are bad - Singletons! No, Singletons are excellent as a pattern. Only the implentation in Java is not very useful with a static method. Inflexible and often hard to test. As most creational patterns, Singletons have been replaced with IoC/DI containers. Those offer more options, creating Singletons -as a concept - being one of them.


"And while it doesn't have the same buzzword appeal, reflection as a language feature may be worth mentioning too. That too is just a workaround to compensate for missing language features. Great, so it lets you inspect a class to see what methods it has? That should never be necessary. If it has a method, I should be able to call it without going behind the code with introspection."

Never used Reflection I suppose. Or any meta programming. Read The Art of the Metaobject Protocol. It's about CLOS! Yes I know, Java has a very weak MOP and CGLIB only goes so far.

He goes on ranting about agile development.

"What does it mean? Anticipating that changes will happen? Testing every part of your code? Working as a team, with other programmers? Get the customer involved? Let them see regularly what you're up to?"

Nope. It means "Individuals and interactions over processes and tools [...]" which a little googling would have turned up. But of course ranting without any knowledge is easier. Knowledge hinders one ranting.

For some real insight into agile, read about Agile vs. Lean. Lots of people like agile because it helps with lean development.

The post is titled "Cargo-cult programming", what he mainly attributes to Java developers. Cargo cult programming? His post is more like cargo cult ranting. Like lots of bloggers - see the two I've written about before - who only parrot what others say about design patterns, functional programming, Java or agile development. Count yourself one more cargo cult blogger.

I hope you've read the original post. It's fun from a certain point of view as you see in this post.

Thanks for listening.

PS: When wanting to comment on his post, his blog told me "Sorry, but it seems you are a Spambot." That says a lot about the blogger, keeping to oneself and not listening to others helps staying without knowledge and helps with more ranting. I hope none of my commentators see a spam bot message 😉

Stephan Schmidt Administrator
CTO Coach , svese
Stephan is a CTO coach. He has been a coder since the early 80s, has founded several startups and worked in small and large companies as CTO. After he sold his latest startup he took up CTO coaching. He can be found on LinkedIn or follow him in Twitter.
follow me