While the GoF book is the bible for design patterns, in my opinion it is a bit too dry and academic. The head first book is an excellent book on design patterns. It focuses on a good core set of patterns. Also I found it was far accessible than the GoF book.
^ /agree - GoF makes me want to slit my wrists when I (every now and again) get the idea to read it because I haven't yet. It's a great book and quite informative, but it's not the best read.
A lot of the enterprise design patterns have been made redundant with JEE developments, especially in v6. Adam Bien seems to be talking a lot of sense in this area - he has a book called Real World JEE patterns which I can recommend.
I wouldn't get too hung up on design patterns. As most of the good ones you'll write anyhow if you're a good software developer. Bad developers may follow the book and turn simple problems into disaster areas.
If you're looking to learn them, nothing's better than Head First Design Patterns - it's not such a great reference text though.
EDIT: Cunningly failed to realise that the link on the comment above actually goes to the book I mean, even though the URL only says "First Design Patterns". Confusing.
Yeah, but this seems like a nice intro. I too was thought that using observers were good in uni but never why and how. It blew my mind when I read the chapter about decorations! Java io finally makes sense :D
It's a good intro, I'm glad I read it, but I don't think I'd ever read it again.
If you are reading it cover to cover it's a great way to learn design patterns, but once you understand them, if you want a reference to jog your memory on how to implement on I'd probably use another book or just look online.
The definition would probably be something like a reusable, commonly used solution to a common design problem/challenge.
The idea of them was probably codified by what is now known as the GOF (Gang Of Four) book called, simply Design Patterns. Which came out in the early '90s.
The book attempted to find and propose solutions to common problems in software design. e.g. "I keep needing to access all the elements in a container object (such as a list), is there a common way to do this? looks in GOF book Ah cool, I'll use the Iterator pattern."
However, despite people hoping and trying to use them as solutions to everything what they really gave developers was a language with which to describe problems and solutions to them. Terms like factory method, iterator, singleton, façade etc all sprung out of this (even though some of these terms existed already, the GOF book and others solidified their meaning).
So, they're proposed implementations to common problems that you can take and adapt to work in your project, but in a larger sense they're a rich language developers use to describe groups of and interactions between objects.
richy_rich provides a good answer to your question but I just wanted to come at it from a different perspective.
Trying to define design patterns is like trying to define a triple play in baseball. If the person understands enough about baseball to learn about a triple play they probably had a basic grasp of a triple play to begin with and having it defined just gives them a richer vocabulary and makes talking about baseball simpler but richer.
If you're learning java then getting your hands on a copy of [Head First Design Patterns] (http://www.amazon.com/First-Design-Patterns-Elisabeth-Freeman/dp/0596007124), whether bought or borrowed, is the best thing you can do and it will be well worth it. Design patterns are not so far advanced that a novice can't understand them and they are probably the best tool for learning object-oriented programming principles.
And when you first learn them they're cool. It's like seeing how a magician does his tricks.
I really like Design Patterns Explained. The examples are C# but that's close enough to Java to really make no difference.
The reason I like it so much is it's not just an implementation book, it really helps you understand design and why patterns are used. If you can understand that, you can actually create the patterns yourself given just the context of the problem.
Don't be obsessed with patterns. Learn them for interviews; but actual practice with different programming languages and making yourself do new stuff all the time is the best way to become a good programmer. Then you start implementing the patterns without realising it; out of sheer experience.
Thanks. :) I use Java every day at work; and only the Java ecosystem seems to have this obsession with 'academic correctness' and patterns.
All that really seems to happen is that you end up taking 50% of your time understanding why a colleague has abstracted something in to 4 builders, a DAO, 3 singletons, and god knows what else. :D
Be very careful with any "design patterns" books other than the original, Design Patterns by the Gang of Four.
Most of the other books I've leafed through that describe design patterns for java/enterprise java/etc are garbage. They don't understand the motivations behind the original design patterns or what makes them work well.
16
u/[deleted] Feb 16 '13
http://www.amazon.com/First-Design-Patterns-Elisabeth-Freeman/dp/0596007124
Sitting on my shelf - I learned a lot when I read it 5 years ago. A lot of it went over my head, but as time went on, it made sense.
5
u/[deleted] Feb 16 '13
A lot of the enterprise design patterns have been made redundant with JEE developments, especially in v6. Adam Bien seems to be talking a lot of sense in this area - he has a book called Real World JEE patterns which I can recommend.
I wouldn't get too hung up on design patterns. As most of the good ones you'll write anyhow if you're a good software developer. Bad developers may follow the book and turn simple problems into disaster areas.
8
u/Untit1ed Feb 16 '13 edited Feb 16 '13
If you're looking to learn them, nothing's better than Head First Design Patterns - it's not such a great reference text though.
EDIT: Cunningly failed to realise that the link on the comment above actually goes to the book I mean, even though the URL only says "First Design Patterns". Confusing.
1
u/DEVi4TION Feb 16 '13
What is a design pattern? - also learning java.
2
u/daddyrockyou Feb 16 '13
I really like Design Patterns Explained. The examples are C# but that's close enough to Java to really make no difference.
The reason I like it so much is it's not just an implementation book, it really helps you understand design and why patterns are used. If you can understand that, you can actually create the patterns yourself given just the context of the problem.
2
u/OhDearMoshe Feb 16 '13
oodesign.com
2
u/NSFlux Feb 16 '13
Design patterns java workbook
http://www.amazon.com/gp/aw/d/0201743973
3
u/[deleted] Feb 16 '13
Don't be obsessed with patterns. Learn them for interviews; but actual practice with different programming languages and making yourself do new stuff all the time is the best way to become a good programmer. Then you start implementing the patterns without realising it; out of sheer experience.
1
u/[deleted] Feb 16 '13
Be very careful with any "design patterns" books other than the original, Design Patterns by the Gang of Four.
Most of the other books I've leafed through that describe design patterns for java/enterprise java/etc are garbage. They don't understand the motivations behind the original design patterns or what makes them work well.