Thinking in Patterns: Download the First Version 82
RichMeraz writes "Bruce Eckel has posted his first incarnation of Thinking in Patterns with Python on his website. What a wonderful Christmas present." Make sure to check the list of mirrors before downloading. As Eckel says, "This should whet your appetite to read
Design Patterns "
(or reread it)... classic book, I figure it can't hurt to refresh my memory once a year, and holidays seem like a good time to think in the abstract...
...if you actually want the book ... (Score:2, Informative)
Use the third link in the story [mindview.net] if you just want to get the book. I didn't even see how to get there from the "first incarnation" link the story poster provided.
file formats (Score:1, Interesting)
It would be nice if this was in HTML or some similar format instead of Word.
Re:file formats (Score:2, Informative)
Re:file formats (Score:1)
OpenOffice (Score:1, Redundant)
Newsgroup (Score:5, Interesting)
Design Patterns are abstract? (Score:2, Interesting)
It's like the difference between Legos and carpentry. Sure, it's a little harder to cut wood to the right length and you nails or screws to put it together, but would you want to live in a house made of legos?
Learn what an algorithm is. Better, learn lots of algorithms. Don't just grab a bunch of patterns out of a bin and slap them together.
Re:Design Patterns are abstract? (Score:5, Funny)
> carpentry. Sure, it's a little harder to cut
> wood to the right length and you nails or
> screws to put it together, but would you want
> to live in a house made of legos?
From this audience, I doubt you are going to get the answer you are looking for.
.
An anti-OO'ers view of OOP Patterns (Score:1)
Relationships as formulas are easier to change and less disruptive of code structure (upon change) than physical class patterns. OOP patterns remind me of indexing files/tables by hand rather than telling the machine to do it. Or, sewing by hand rather than pushing a pattern button(s) on a sewing machine.
P/r is more abstract and less primative in this sense.
http://geocities.com/tablizer/prpats.htm
Re:Design Patterns are abstract? (Score:5, Informative)
My favorite example of a pattern, from the original "Design Patterns", is the porch. A porch is a transition between the inside spaces of a house & the outside. It should allow you to greet a person at the door, converse with him there, and decide whether or not you wish to allow him into the inner sanctum of your home. It should be at least 6 feet wide, to allow room for a few chairs, a table for a drink or book, and still allow somebody else to pass. It should be close to the street, but not so close that you are forced to be a part of the public street scene. It should have a low wall or divider so that you can be seated and hear what is happening on the street and be a part of it but still maintain your privacy to read a book or converse with friends. The wall should be low enough so that you can stand or move your chair by the wall, and from there see what is happenning, become a part of the public life on the street, greet a passer-by.
Alexander spends several pages describing how a porch is to be used, what problems it solves, how it interacts with other patterns
Re:Design Patterns are abstract? (Score:1)
Re:Design Patterns are abstract? (Score:1)
My library is packed away & in-transit with the rest of my office. New company, new office, same old job
Re:Design Patterns are abstract? (Score:5, Informative)
I tend to agree, though not for the same reasons. It a lot of ways, object-oriented programming has gone over the top, in that what would have been simple designs are turned into OO monsters that no one can understand. Patterns are a response to this. They provide a way of classifying and approaching problems in a structured OO way that keeps the programmer focused on the pattern and not on over-engineering a custom solution (spaghetti programming + OOP = ravioli programming). The obvious flaw here is that perhaps such a heavy reliance on OO-ness for *everything* isn't a good idea. After all, it's only certain groups of programmers that find themselves being sucked into the pattern dogma. Other programmers without strict OO hangups don't understand the reliance on patterns.
Re:Design Patterns are abstract? (Score:1, Redundant)
LOL!!!!!!
+5 funny
Learn algorithms *and* patterns (Score:4, Insightful)
Most of what we do is solve practical automation problems for people. You know, the kinds of problems that are never going to get the attention of hundreds of Ph.D. students, all intent on outdoing each other in terms of elegance and brilliance.
Most automation problems get worked on by a series of programmers. There's the original developer, and after that person moves on to greener pa$ture$, maintenance staff. In a situation like that, if you can't say in the documentation that the original problem mapped to a certain well-known algorithm, the next best thing is to say that you implemented the algorithm using a set of patterns.
If you do so, then you'll clearly communicate what was done, making it more likely that proper maintenance decisions are made (including, perhaps, the decision to replace the poorly thrown together patterns of the original implementation).
Re:Design Patterns are abstract? (Score:4, Interesting)
Nonetheless, programmers often have to solve very similar problems with very similar structures. Design patterns allow us to categorize those problems and structures in a very efficient way. Can they be abused? Absolutely. That doesn't mean you should dismiss the entire dicipline out of hand. I've also found that bad programmers are much less likely to be aware of patterns, as they don't tend to keep up with their profession as well as the good programmers do.
Re:Design Patterns are abstract? (Score:3, Insightful)
Design patterns is a very general term. To say you "don't use patterns" is like saying you "don't use algorithms". Programmers use algorithms, and design patterns, whether they know it or not. A programmer who lacks the discipline to study basic programming concepts is indeed lazy, ignorant, and a bad programmer.
Perhaps you meant: if a programmer finds his current methodology satisfactory
Re:Design Patterns are abstract? (Score:2, Insightful)
In any case, I think the case for studying design patterns is a bit weaker than that for algorithms which has stood the test of time.
There's so much competition for programmers' attention these days it's hard to tell the latest fad from something of real value. I'm sure advocates of every programming paradigm believe everyone should rush to study it, but the reality is that there just isn't enought time. So we each have to make our own judgement about what is important and we should avoid labeling others just because they don't share our enthusiasm for a particular method.
Re:Design Patterns are abstract? (Score:2)
That's a big if. I'm sure there are a few rare geniuses who can re-invent this sort of thing, and fewer still who refuse to read anything and have such talent, but such people are the exception and not the rule.
In any case, I think the case for studying design patterns is a bit weaker than that for algorithms which has stood the test of time.
Design patterns are not new, the expression "Design patterns" is. Many design patterns have been used for a long time before the "Design patterns" book was written (the "cursor" or "iterator", polymorphism, factories, etc) Coplien's "Advanced C++ Programming Styles and Idioms" book was written in '91, and this book describes many of the patterns in GoF.
There's so much competition for programmers' attention these days it's hard to tell the latest fad from something of real value.
Solutions to classic programming problems are not "a fad". I believe it's a misconception that design patterns are a "fad", or even that they are "new".
'm sure advocates of every programming paradigm believe everyone should rush to study it, but the reality is that there just isn't enought time.
Again, "Design patterns" is not a programming paradigm. It is more general than that. There are design patterns that relate to functional, procedural, generic, and object oriented programming. Design patterns is about the science of programming, not about the science of programming in a particular style.
Re:Design Patterns are abstract? (Score:1)
Keep in mind that most of the programming that has ever been done predates the study of design patterns and most of this code was written by average programmers. That not to say that studying design patterns has no value, but obviously it is not a minimum requirement for writing useful code.
"Design patterns are not new, the expression "Design patterns" is....Coplien's "Advanced C++ Programming Styles and Idioms" book was written in '91, and this book describes many of the patterns in GoF."
Well, I see what you're saying but I think we're going to have a problem discussing this subject if we fuzzy-up the time-frame. Design patterns is supposed to be a formal subject and so I think it's appropriate to date it from the time it was first proposed. In any case, I'm not sure even a decade is long enough to declare victory.
"Solutions to classic programming problems are not "a fad". I believe it's a misconception that design patterns are a "fad", or even that they are "new"."
I never said that design patterns were a fad, I said that it's hard to determine whether any particular method is a fad or not. It takes a lot of time to evaluate these things and if you investigate it and it turns out to be less than great you've wasted a lot of time.
"Again, "Design patterns" is not a programming paradigm. It is more general than that"
Well, I think the problem is that you have a narrow definition of what a "programming paradigm" is. But let me restate what I said in a way that doesn't conflict with your definition: I'm sure advocates of every methodology for any aspect of computer science believe everyone should rush to study it, but the reality is that there just isn't enough time.
Re:Design Patterns are abstract? (Score:2)
Again, design patterns aren't new, only the terminology is. Most of the programming used design patterns in their various forms, they just weren't called "design patterns".
but obviously it is not a minimum requirement for writing useful code.
But it is. You show me useful code, and I will show you design patterns. C programmers might not have talked about using "the bridge pattern", "the iterator pattern", and "polymorphism", but these patterns are often used, and were understood to be important software design concepts.
Well, I see what you're saying but I think we're going to have a problem discussing this subject if we fuzzy-up the time-frame.
No, you're going to have trouble making your case if we fuzzy up the time frame.
I said that it's hard to determine whether any particular method is a fad or not.
Design patterns are not "a particular method". The study of design patterns is the study of programming methods that address software design problems. To say that design patterns are "a fad" is to say that software design is a fad. Regardless of what they were called, or what they will be called, design patterns will last as long as people care about software design.
Well, I think the problem is that you have a narrow definition of what a "programming paradigm" is.
So what do you consider to be a programming paradigm ? In fact, name as many as you can.
I'm sure advocates of every methodology for any aspect of computer science believe everyone should rush to study it, but the reality is that there just isn't enough time.
Design patterns is not a methodology, it's the study of methodology for an aspect of computer science (namely, solving software design problems). If you can show me a methodology to solve a certain type of software design problem, I can show you a design pattern. To say that you "don't have enough time" to learn to design software is a copout, and it's inexcusable.
Re:Design Patterns are abstract? (Score:1)
Your missing the point which was that all of this software was written without the "study" of design patterns. If the "study" of design patterns merely means doing stuff programmers have been doing all along than there's no point in reading any books on the subject. If, in fact, there are new ideas in these books (as I believe there are) than they may be worth reading but again reading these books is not a requirement for writing useful code since useful code has been written prior to the publication of the books. This is as clear as I can make it so I'll stop with this post.
Re:Design Patterns are abstract? (Score:2)
Given that most modern programming environments come with facilities that implement many if not most of the commonly used algorithms in very carefully optimized form, yet do not contain similar pre-cast design patterns I am not so sure that a programmer would benefit more from studying algorithms than design patterns.
I guess I'd say that it depends on the nature of the task at hand. If you are writing a database, then clearly a strong knowledge of algorithms is critical. But if you are putting together an e-commerce web site that is backed by a pre-existing database, then I think that the there is more to be gained from an understanding of design patterns than algorithms.
Re:Design Patterns are abstract? (Score:1)
My point is that there is a consensus among programmers (at least to the extent that we can agree on anything) that studying algorithms is useful. Such a consensus doesn't yet exist for design patterns although it might someday.
Re:Design Patterns are abstract? (Score:2)
I wish I could show some of the coding atrocities I've had to deal with over the past couple of years without having to worry about the companies I worked for suing my ass off. Then you could decide for yourself. Without seeing their code, you pretty much have to take my word for it.
There was the guy at the Evil satellite TV company who was a Windows/C programmer originally when they threw him into a Linux/C++ project. He ended up trying to reimplement MFC with GDK, and doing it badly. Every class inherited from every other class and you'd frequently have to change the whole damn class hiearchy to do something like add a button to a screen (The interface was more screen based than window based in his model.)
Then there was the guy at the Evil blue company who took 6 months to write a badly factored report module that was basically fortran code wrapped up in object wrappers. Yes, this paradgim did work for him, but it doesn't work for me, or the next poor bastard who has to support and extend that code. Many of the OO programmers in my department are structural programmers who have not learned (nor have any interest in learning) Object Oriented programming style.
Two bad programmers in a sea of bad programmers. Ask either of them if they know about design patterns and they'll tell you they've never heard of them (I know because I did.) Circumstatial evidence, true. Also perhaps coincidentally these people also go home to wives and kids. But so does Linus, so I'm not sure how much of a factor actually having a life has on the quality of a programmer you are. But now I'm just rambling...
I agree with you wrt. the moderation of the parent comment and can only hope I get that one in metamod.
Re:Design Patterns are abstract? (Score:3, Insightful)
Would you want to build a house by starting with a handful of acorns?
Unless you write software by scribbling hex codes onto a legal pad, then entering them into the front panel of your box a byte at a time, you are probably taking advantage of quite a lot of pre-fab, pre-tested software artifacts that make your job easier. Like editors, compilers, operating systems, libraries, etc. Design patterns, like compilers, are another step toward automating the nitty-gritty details of a software development project. Nothing more. Like other tools, there are times when they're a great help and times when they're innappropriate.
Why would you draw a line in the sand at any particular level of abstraction and say "Beyond this line lies the path to crummy code?" Crummy code was in plentiful supply when assembly was the language of choice, and it will continue to be in plentiful supply when Java sounds as modern as COBOL sounds now. The tools don't create or destroy crummy code - people do. And until we get the people out of the process (hold(mybreath)!=1), software quality will continue to run the gamut.
Re:Design Patterns are abstract? (Score:2)
Re:Design Patterns are abstract? (Score:4, Insightful)
My background is that I had been using C++ for several years and even had a graduate level OO class (text was Booch) before I read the Design Patterns book. Though a fairly intelligent guy, perhaps I do solve problems a little slowly, but in any case DP was like pulling the scales off my eyes.
DP provided thorough discussion and examples of how OO language features co1uld be put to good use. It answered the question, What is oo good for?
Nowadays, I recommend to anyone learning C++ to read DP so that actually can understand the usefulness of OO languages.
Many many programmers don't get exposed or trained in the way OO. STL code is one way they can get exposed to the possiblities of oo design (though the STL is probably a bit overwhelming and limited). The most popular oo framework, MFC, is written as though the implementers didn't (don't) understand oo and many of the people teaching C++ courses don't understand it either.
Patterns seems to me the most effective way of teaching the possibilities for real-world problem solving with oo. IMHO, of course.
Re:Design Patterns are abstract? (Score:2, Informative)
STL has very little to do with OO design, there is little to nothing in the way of class heirarchy, and the polymorphism is largely static. STL is for the most part about generic and functional programming. I don't agree that it's "limited", but it certainly is "a bit overwhelming" (to put it mildly)
Re:Design Patterns are abstract? (Score:1, Funny)
We have some here at Legoland in the Mall of America. You'd need a sledgehammer to go through the models of the earth and the moon floating in the air. And judging by some of the quality buildings we have around here I bet some people *would* have preferred their builders would have used legos.
Re:Design Patterns are abstract? (Score:1)
I'm passing out from the happiness induced by mere consideration of this idea...
Oh, and you are wrong about Design Patterns. It's a great book that helps break old procedural patterns of design, and helps to define a set of OO concepts from which actual implimentations can be made. If you have people trying to impliment those patterns like monkeys, I don't think they understand... it's a book, it's a list of ideas.
They also show how to write an OO parser, and say, don't do this. It's a book about thinking. About asking, how can this system use cooperating objects.
AND: learn algorithms?!?!?! Talk about boilerplate solutions!
Better yet (Score:3, Informative)
Better yet - learn what makes a good algorithm, AND learn proper design patterns and best practices. Yes, you can think on your own while at the same time observing and learning from people who have had the same problems before you did. The authors of the book "Design Patterns" correctly observed that the same problems are being solved over and over again, and it would be helpful to come up with a list of elegant solutions.
I do admit I've seen some poor programmers falling back on design patterns, and what you get is a bloated product thats functionality has been twisted so that patterns could be used. But the problem there is with people trying to force their problem to fit within a pattern.
Plenty of people have had a programming problem similar to the one you are encountering now, and yes, some of them came up with a better solution than you did. A good programmer should be able to come up with his/her own algorithms, but recognize situations where other people have already done it better. Suppose a programmer dies today, and I have to come in and support his code. Personally I'd rather look at code that followed some established best practices, than code that was written by someone who felt he had to reinvent the wheel.
Agreed, though, design patterns are certainly not abstract. They are merely directions on how to apply a decent solution to a problem.
Re:Design Patterns are abstract? (Score:1)
Learn what an algorithm is. Better, learn lots of algorithms. Don't just grab a bunch of patterns out of a bin and slap them together.
But the truth is...
There is a market and legitimate use for clipart.
The same is true for code snippets (provided they are universally global calls or local OOP code unlikely to be duplicated by accident).
The trick with clipart is having a user wise enough for them not to overuse it or accidentally imply the exact opposite of what the clipart is meaning to convey.
The trick with code snippets is to make them universal like an #include library call or ungoofable internal code calls.
The basic goal of both is to speed up making a workable product without requiring a genius or artist for the person trying to output useful and error-free results. I view a book like this in the same manner as "Numerical Recipes in C" or books of circuit diagrams. There will have to be a brain in the person hoping to use these, but they don't have to waste time reinventing the wheel (though there is nothing wrong with that).
Don't forget to buy a copy too (Score:5, Insightful)
Re:Don't forget to buy a copy too (Score:3, Insightful)
Don't forget to *review* it too (Score:2)
Eckel's announcment (on comp.lang.python) (Score:1, Redundant)
http://groups.google.com/groups?as_umsgid=mailman
Clarification (Score:4, Informative)
From the preface, it appears to be a port of "Thinking in Patterns with Java" to Python, with the hope of completing the Python version and then porting it back to Java. He (Bruce Eckel) makes clear that this is not a Python tutorial.
You can get the complete explanation from the horse's mouth, but I figure it'll be slashdotted soon.
this is not 'thinking in patterns' (Score:2, Informative)
Aspect oriented programming (Score:3, Interesting)
I've been using the "patterns" as described in books such as the gang-of-4 one for some years, but I'm not actually happy with the whole thing. Beyond all the hype on patterns, it doesn't seem to deliver the level of reusability and abstraction it is supposed to handle (you may say it's my fault as a software designer, but I'm sure the paradigm lacks something - it's definitely not incrementally productive for large scale projects).
It seems that the Aspect Oriented Programming paradigm is getting more attention because people is beginning to suffer with the bloat these patterns cause when used per se. There are some good AOP implementations for Java (AspectJ and Hyper/J), and one for Python (Transwarp, which is quite well engineered, although I couldn't make it work..). I strongly suggest that you take a serious look at AOP if you are a serious software designer.
Re:Aspect oriented programming (Score:2, Insightful)
The problem is that patterns are not really a new thing, they are a way of expressing tried and true software design concepts. Patterns are not going to radically change the world (because they're not a new thing), but having someone bother to write down advanced programming techniques does make it easier for programmers to learn about software design.
Patterns and Usefulness (Score:3, Interesting)
Bruce Eckel (Score:2)
Bruse Eckel's books are some of the best resources for delving into the world of programming witout having a CS background. "Thinking In Java" was my first introductionto Java and his writing made it very approachable.
Then I discovered his website [mindview.net]. What a treasure trove. Updated book releases and drafts of future publications. I've even downloaded a few of his recorded seminars. Great stuff and all of it free. I gues he figures he'll havea better product when it hitsa the street and maybe a few more customers if their appetites have been whetted by the drafts.
I may not be the best programmer, but reading Bruce Eckel's writing helped me kake up my mind to change my profession to programming. Nother is better than a teacher that loves what he's teaching
Re:Bruce Eckel (Score:1)
The problem with patterns (Score:2, Funny)
#define _CONCAT(X,Y) X/**/Y
I'll list three more examples to make the point clear. On the Xerox STAR workstation, the BITBLT instruction was used to perform database range queries - e.g. give me all the servers in the network that support file serving.
As a second example, the MESA signal facility was used during the expansion of mailing distribution lists to detect circular expansions (e.g., raise a "Have_I_Seen_This_One_Before?" signal, go up the stack looking for matches on the signal arg, if there is no match, fall through the signal handler and continue the recursive expansion).
A fourth example is the way that the "C" switch statement is the ideal construct for parsing command-line arguments in a UNIX shell command.
Now in the object-oriented world, people do not want to be bothered with the problem of reading others code, or thinking for themselves, so they go for these trendy "design patterns" books where other people do the heavy lifting or simply make up garbage to see if it will sell. This lets the average or below-average programmer off the hook and relieves them of the burden of forming their own opinions and developing their own tastes in programming.
This is evil in it purest form. It is the an example of the same laziness that has us receiving 95% opinion and 5% in every news story reported today. This laziness have moved outside the news room and is invading software engineering.
We're all dumber as a result of this trend !!!
Re:The problem with patterns (Score:1)
I think you're missing the point of OO.
It frees the programmer from having to worry about creating their own 'style' or learn how to do tricky CONCAT's, database queries, etc. If I'm not worrying about bits and trivial programming tasks that have been solved many times over (usually better than I could solve them), then I can more easily approach complex problems. I'm not thinking less, I'm thinking differently.
The time I save by never having to think about x.concat(y) is spent learning even more design patterns and OO API's. In short, I become a better, more versed programmer because I do not have to stare at other ppl's code.
Re:The problem with patterns (Score:1)
Actually, the biggest problem with multiple dispatch is that it's simply a complex problem, because you have to worry about tuples of arbitrary subtypes.
Read your Design Patterns book more closely; most of the patterns are probably ways to work around the brokeness and/or inflexibility of the underlying language (C++, even Java/Python).
What you call a "work-around" I call an "idiom". Static typing results in a certain degree of inflexibility, but provides a certain degree of pre-runtime checking. I would say that a lot of the items in GoF give the programmer the flexibility of an interpreted language with static checking.
I'm not sure why you lump python in there btw -- most of the items in GoF are more or less trivial to implement in python.
Re:The problem with patterns (Score:3, Insightful)
This is not true at all. The whole point of studying design patterns is to study someone else's tried-and-true solution to a software design problem. It is not a substitute for forming ones own opinions. It's a tool for forming informed opinions as opposed to spouting ill-founded nonsense like your average slashdotter.
Re:The problem with patterns (Score:1)
I mean, it's not the goal, but many programmers just use them saying it's God on Earth, without trying to have their own opinion. Why ? Many (bad) reasons, the main being : because that way "the next programmer who will read the code will understand straight: you just have to say 'this code follow the Observer pattern', and he will understand everything straightforward". NOOOOO !!! Code is understandable because it is written clearly (good indentation, and stuff), with good specs, docs and everything (javadoc is far more useful for the programmer than design patterns if u want my opinion).
So, theoretically, u're right. Practically, unfortunately, u're far from always right (((((((((((
Re:The problem with patterns (Score:2)
Re:The problem with patterns (Score:2, Insightful)
The porch example above, you will notice, says nothing of how to construct the porch, merely how it relates to the house and the people. It is not meant as a replacement for a skilled carpenter who knows how to create a porch that can withstand the weight needed or how to pour the foundation so that it lasts 30 or 50 years.
So the fact that a contractor or architect can use the language "they need a porch" has very little bearing on the quality of the implementation of that porch. Of course, when building systems, if you can say "he needs a porch (or a factory, etc), you don't need to spend days or weeks figuring out what a porch does, and you can actually focus on how you will implement this porch.
The fact that you are using an example in C doesn't help your argument. Nothing stops an OO programmer from reading others' code to see implementations of algorithms OR patterns. I don't know where the comment "...in the object-oriented world, people do not want to be bothered with the problem of reading others code, or thinking for themselves.." is coming from but that has certainly not been my experience with programmers in the OO world.
Re:The problem with patterns (Score:1)
You shouldn't be reading code to figure out design. You shouldn't be writing code yet either. That's what the DESIGN phase is all about: you have to figure out the way you're going to solve a problem at an abstract level.
Design Patterns, like almost every design tool, says nothing about implementation. They don't even say anything about what algorithms will be used in the implementation, that's a lower level of abstraction you also have to deal with.
If I remember correctly, "Design Patterns"'s authors spent a great deal of time trying to make that clear.
When you're finally implementing the design you may and probably should go and read all the code you want to learn little implementation tricks as you're implementing your algorithms. That's an EVEN LOWER level of abstraction.
Maybe it would be nice to have a vocabulary for the sintax patterns you use in a particular language, such as the ones you mention. "Hacking patterns"?
But if you're confusing that with software design, then you are sorely mistaken.
The book is not good for patterns. (Score:1, Interesting)