3 ms·
paraphrased: "In C++/Java, you write an iterator again and again for every collection" No, you don't. If you write them yourselves (which is in most but all ca
by eropple 15y ago
paraphrased: "In C++/Java, you write an iterator again and again for every collection"
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.
- nagnatron 15y agoHave you read anything by Alexander?
- eropple 15y agoI haven't, but I'm not looking at what he says. 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.
- loup-vaillant 15y agohttp://perl.plover.com/yak/design/samples/note.html http://perl.plover.com/yak/design/samples/note.html 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.
- kenjackson 15y agoI don't understand how design patterns can't exist in any language. I'd even argue its the existence of design patterns that make programs readable at all. I can look at code and say, "ahh... case analysis."
- johnzabroski 15y agoI can look at code and say, "ah, Alan Perlis, you were right when I read your advice when I was 11 years old, but did not understand your wisdom [1]": 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. [1] http://www.cs.yale.edu/quotes.html http://www.cs.yale.edu/quotes.html
- eropple 15y agoThat would be because they (obviously) do exist. 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.)
- loup-vaillant 15y ago> That would be because they (obviously) do exist. 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 http://www.loup-vaillant.fr/articles/classes-suck
- jerf 15y agoFew sensible C++ developers in 2002, let alone earlier, could or did use STL iterators, generics, or templates on a large scale. Yes, they all technically existed, but it wasn't something you'd put in production code yet. The ideas and prototypes were a few years old at that point, but the shipping libraries were very new, and if you were trying to write cross-platform you couldn't count on them existing at all.
- kenjackson 15y agoMaybe my team wasn't sensible, but the main reason we were using C++ in 2002 was for the reasons you described. We admittedly weren't cross platform, but we found the features compelling -- and while maybe not as stable as we'd like -- still more stable than most JVMs that were all the rage.
- eropple 15y agoSame here. I was writing C++ with templates and the STL in 2002. 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. ;-)
- shadowfox 15y ago> Few sensible C++ developers in 2002, let alone earlier, could or did use STL iterators, generics, or templates on a large scale 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.
- roel_v 15y agoThat is simply not true for 2002. Maybe for 1995, but then again, what did we have in 1995? Even Java was only released in 1995 according to Wikipedia - even in 1999 it was still a hot new thing that was mostly used by early adopters.