Design patterns aren't
perl.plover.com
perl.plover.com
His summary: "We need to take a fresh look at Christopher Alexander."
That's all well and good, and as far as I know the concept of pattern languages could be very useful; I wouldn't know, I've never heard of it till today, and in fact still have no idea what it's about. Which brings me to my point, which is to wonder why the author chose to waste an entire 5 minute and 13 slide presentation (5 of which were dedicated just to bashing design patterns) to making the point that "we need to take a fresh look at Christopher Alexander," instead of, say, spending more time introducing Alexander's ideas and presenting ways they could be useful in our domain.
I will conclude by pointing out another pet peeve of mine, which is sensationalist titles only tangentially related to the content. Design pattern, most certainly, ARE. What they are NOT is pattern languages, which is a similar sounding but entirely different concept.
</ grumpy geezer mode>
TL;DR: Gof had in mind C++ and Smalltalk. Some languages eliminate the need for many of the patterns in GoF, and they don't eliminate the idioms (patterns for a particular language), as they barely cover it.
Another good info on the subject is this presentation: http://www.infoq.com/presentations/Functional-Design-Pattern...
Yeah, it's definitely not a good set of slides unconnected to the talk. He even admits that.
Does not follow. It is also possible that he has made a hard point, which the brains of the readers have a hard time representing with their internal conceptualizations, therefore misunderstand, then act on those misunderstandings. I think the presentation is perfectly clear, and do not see any obvious way it can be made wildly easier to understand.
Quality of communication is not just bounded by the quality of the sender, it is bounded by the quality of the recipient as well. The point this presentation is trying to make is intrinsically hobbled by the fact that many people cognitively will only perceive something that boils down to "PATTERNS GOOD" (hooray!) or "PATTERNS BAD" (boo! flames!), and "PATTERNS DOGMA A LOSSY TRANSLATION OF SUPERIOR ORIGINAL PATTERNS CONCEPT" doesn't into either of those buckets very well (the distinction between patterns dogma and patterns idea being a tricky one all by itself), and if that's how one approaches it, it's easy to see how it simply falls into the "bad" bucket.
A year or so after reading the GoF book I saw the Alexander book in a used book store and picked it up to see what it was all about and I was very surprised. I like the book a lot but I really don't think the parallels with the GoF book and the software design patterns are all that strong. The Alexander book does not seem very systematic or analytic, it's more rambling and philosophical. I'm not an architect so I probably don't see the big picture but to me the book seems to lack a coherent vision.
If you're interested how Alexander himself saw himself fit into the emerging pattern movement, here's a link to James Coplien's description of Alexander's OOPSLA appearance in '96: https://sites.google.com/a/gertrudandcope.com/info/Publicati...
Hard to believe it's been 15 years!
No, you don't. If you write them yourselves (which is in most but all cases the wrong approach, what with the Java libraries and the C++ STL), you use templates or generics, as appropriate, to define reusable ones.
In many cases, proper patterns are reusable--and in many cases for good programmers, design patterns occur automatically just because they're a logical way to do something. I don't set out to create flyweight objects, they're the simplest way to achieve my goal. I don't write a thread pool just to create a thread pool, I write a thread pool because it makes sense.
Even in 2002, this was the case. I don't get the feeling that the author of these slides knew either well enough to make the claims he made.
.
The Gang-of-Four idea is to discover existing patterns of software development / Then program people to implement them habitually
Er...no. The book Design Patterns is descriptive, not prescriptive. Is that so hard to get?
.
I am by no means a C++ fan, or even really a GoF fan, but this post is slagging it just to slag it. If you want to slag it after you understand it, by all means (and I have perturbed a great many electrons in doing so, myself), but it doesn't sound like the author does, at all.
I'm looking at what appears to be the author of these slides, taking a very strong point about something about which he demonstrates little knowledge. No, the GoF stuff isn't the same as what (it seems like) Alexander is saying. That doesn't make it wrong, and it doesn't mean this author isn't misrepresenting the GoF in the linked work.
The GoF, are not the Design Pattern Police, demanding that you tack Strategy and Command and Memento objects everywhere. It's observational material based on seeing many people reinvent essentially the same wheel over and over again.
He didn't want to criticize the GoF book. He wanted to say that C++ and Java suck because they need Patterns. PG also said as much. Quote from the link above :
> I am not saying "design patterns" are a bad idea. GoF-style design patterns seem to me to be an interesting and valuable idea, worth studying and developing. Even in their least interesting form, people do need to work around the severe deficiencies of C++, and if "design patterns" help them do that, it's a good thing.
This comes off as people strangely perturbed about the popularity of Something They Don't Like to me. (Paul Graham's own comments on the matter included.)
Spot on. Now what? Well, you could for instance ensure that the most common patterns are as readable as possible. Most of the time, that means adding special support for them, or let the user write such special support.
Case analysis, for instance, is a pattern. Now you can implement it with nested `if`, or you can use a `switch` statement (if your language has either `switch` or macros). Personally, I prefer the `switch` statement, which at a glance makes clear what pattern is used.
GoF patterns are useful. The shame is C++ and Java's inability to properly implement them. Really, if you often use mixins, maybe you need closures. If you often loop over data structures, maybe you need `map` and `filter` (as closures or special syntax). And so on.
GoF patterns don't suck. They just highlighted how much C++ and Java sucked, by showing how much copy-paste you have to perform. In an ideal world, patterns would only be instantiated once: in the compiler or in a library.
On a related note, here is why I think C++ and Java suck, badly: http://www.loup-vaillant.fr/articles/classes-suck
10. Get into a rut early: Do the same process the same way. Accumulate idioms. Standardize. The only difference(!) between Shakespeare and you was the size of his idiom list - not the size of his vocabulary.
Of course, I was also 14 years old and working alone on toy projects, so I didn't have to worry so much about any of that. ;-)
This may be far too much of a generalization. The team I worked in was making heavy use of templates by about 1999. Now it was true that no compiler implemented the full standard and you often needed workarounds. But many developers clearly saw the utility and made use of the fact.
As far as I'm concerned, GoF is (or at least should be treated as) a taxonomy, not a cookbook.
The fact that people use it as a cookbook is not necessarily the fault of the authors.
That's pretty much what Alexander's books say.
The failure of GoF, in particular, is that people took it as a golden rule for every environment. IIRC, the examined source code was all object oriented c++ and smalltalk code. Yeah - it's not surprising that those patterns aren't going to work well in, say, Haskell.
+1
Back in the days of C when assembly was still important, calling conventions represented patterns that ensure the stack got cleaned up properly. We may no longer talk about it, it is still there, doing its work silently. The design patterns were harvested from a language that didn't support lisp-style macros or continuations or closures.
Patterns are helpful for people who have to work with particular languages, but are not particularly useful to language designers. But then, they [language designers] already know that.
It has a lot of examples which fold into one liners in dynamic languages or are simply "the way it could be done" instead of a pattern (they don't require additional code or attention - see abstract factory).
The article/presentation seems to imply the benefit of domain-specific languages for capturing the software requirements (which is what Alexander's "Pattern Languages" sounds like to me).
How to properly create and re-use DSLs sounds very much like an artform to me...
Find the right abstractions that gives you the right amount of details while at the same time give you the tools to scale your reasoning about a problem, and you can move mountains. Find the wrong balance, and you will end up with a cluttery hell that is impossible to maintain or a blunt tool that doesn't do anything well.
The truth is, "LIGHT ON TWO SIDES OF EVERY ROOM" is also a mean - a mean to making a room more bright, pleasant and friendly . If it feels more substantial than an iterator pattern, it's just because we directly interact with an architecture of a building in contrast to the architecture of a software, which is always hidden.
There's nothing wrong with GoF, it just follows from the essential quality of a computer software.