Wednesday, June 8, 2011

Hey GOF, It's not a good metaphor unless you can drop it on your foot

I read a recent article about the importance of writing physically. Fundamentally, the author says that "writing physically" means writing about things you can drop on your foot. This means a lot to me because when trying to write software, I'm constantly translating ideas into mental pictures of physical things.

To this end, I think the Gang of Four have done a disservice to the software industry by pushing design patterns that have no representation in the real world. Worse than this, pushing UML as a way to represent and communicate software design leads to situations where everybody THINKS they agree, but they in fact all are thinking about completely different things.

As a specific and very simple example, lets look at the Command pattern. Reading the explanation is very dense and rife with jargon that is specific to the particulars of Object Oriented programming languages. For folks who need to read the explanation, who typically are new to OO programming, these explanations just make things more complicated.

My simple explanation of the command pattern is: You a rich person who has an entire staff of servants who all speak different languages. Instead of trying to tell them what you want, you've instructed someone to build "command boxes" that have a button you can press and will then instruct your servants to do what you need them to do in their native language. This is the command pattern in a nutshell.

With my physical example, we can now have a good discussion about how to implement this in software. Using the UML and other rigmarole on the oodesign site, it's nearly impossible to even have a coherent discussion because there is nothing in the real world to talk about. When living in the world of ideas, it is very dangerous to assume everyone sees the same pictures in their heads as you.


Anonymous said...

Your metaphorical description of the command pattern is excellent; very meaningful and concise. More of this in CS / programming literature would I think be very beneficial.

me said...

That's good to hear... I always feel like the lonely dummy in a room of geniuses when people try to explain this stuff using totally abstract ideas and I don't get it. I suspect more people than you and I are in the same boat, but nobody wants to raise their hand and look stupid.