Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

A little about Design Patterns

  • Loading branch information...
commit 7faab9840addef16953df3b72248992e52a90dde 1 parent 53eae09
@unclebob authored
Showing with 159 additions and 0 deletions.
  1. +159 −0 uncle-bob/_posts/2014-06-30-ALittleAboutPatterns.markdown
View
159 uncle-bob/_posts/2014-06-30-ALittleAboutPatterns.markdown
@@ -0,0 +1,159 @@
+---
+layout: post
+title: "A Little About Patterns."
+tags: ["Programming"]
+---
+
+> _Can you name a Design Pattern?_
+
+A Design Pattern? You mean from the '90s?
+
+> _Yes, they were made popular in 1995. Though they are much older than that._
+
+There was a book wasn't there?
+
+> _Yes, it was named Design Patterns: Elements of Reusable Object-Oriented Software._
+
+Written by four guys.
+
+> _Correct, "The Gang of Four": Eric Gamma, Richard Helm, Ralph Johnson, and John Vlissides.[1]_
+
+It's kind of old and out of date now, isn't it?
+
+> _What makes you say that?_
+
+Well, there are newer books.
+
+> _Indeed there are many newer books on the topic, and some are quite good; but none are quite so impactful and insightful as the original._
+
+Anyway, the whole idea is old and broken.
+
+> _Broken?_
+
+Yeah, like, I've heard people say that Design Patterns were invented to fix some problems in Object-Oriented Programming.
+
+> _Some problems? What problems?_
+
+I dunno. That's just what I've heard. Like, Design Patterns were really just workarounds for bad languages.
+
+> _Bad Languages? Like what?_
+
+I Dunno -- like, maybe C++ and Java. You know. Static languages.
+
+> _What a strange thing to say. Smalltalk, a dynamic language, played a significant role._
+
+Well, and anyway, they don't really apply to the future, with Functional Programming and all?
+
+> _My Goodness! What Nonsense!_
+
+Well, that's just what I've heard.
+
+> _I think you've been listening to the wrong people._
+
+It was just twitter and facebook and stuff.
+
+> _Ah, I see. Social Networks: The font of all wisdom and knowledge._
+
+Yeah, OK, I get your point.
+
+> _I hope so; but just in case let me be perfectly clear..._
+
+That's what politicians say when they're about to lie to you.
+
+> _... (sigh)...Listen ... Carefully. The Design Patterns book is one of the most important books, if not THE most important book, written about software within the last 20 years._
+
+Oh, come on now. It's twenty years old. I mean maybe it was great way back in the nineteen hundreds; but this is like the twenty-first century. We've got Ruby. We've got Clojure. We've got Node, and Angular, and Rails and IOS and Mobile and ... I mean ... Software's changed a lot! We've outgrown all that old stuff.
+
+> _You think software has changed in the last 20 years?_
+
+Well, of course! I mean... Duh.
+
+> _You have much to learn about what the word "Change" means. In fact, the fundamentals of software have changed very little in the last four decades._
+
+How can you say that? I mean, look at all this new stuff!
+
+> _You mean the glitter?_
+
+Glitter!! Are you calling Rails, and Angular, and Node and... Glitter?
+
+> _Yes. Glitter. It sparkles for awhile but it doesn't last. There's always more glitter to follow._
+
+But there are some really great ideas in those frameworks. How can you call that glitter?
+
+> _The ideas aren't glitter. The frameworks are. Most of the ideas in those frameworks are old. They've been around for decades. The ideas are ... Design Patterns._
+
+Wait. Are you saying that Active Record is a Design Pattern?
+
+> _Of course it is. Or rather there are several Design Patterns within Active Record. Active Record is a unique combination of many very old, tried and true, patterns of software design._
+
+OK, now hold on. Just what _is_ a design pattern?
+
+> _A Design Pattern is a named canonical form for a combination of software structures and procedures that have proven to be useful over the years._
+
+Named? Canonical? Huh?
+
+> _Yes, every Design Pattern has a name and a canonical form. Professional software designers use those names and forms to communicate with each other. When they see the name of a pattern in software, or if they recognize the form, then they immediately know the designer's intent._
+
+Can you give me an example?
+
+> _Sure, here are two that are not from the Design Patterns book. Model-View-Controller and Dependency-Injection._
+
+Those are Design Patterns?
+
+> _Of course. They have a well-recognized name, and they have a canonical form._
+
+I get the name part; but what's the form?
+
+>_Well, take MVC. You'd expect there to be three objects, a model object, a controller object, and a view object. The Model handles the business rules. The Controller handles input. The View handles output._
+
+And I put the models, views, and controllers in different directories.
+
+> _Uh, well, Yes! In certain frameworks that has become part of the canonical form._
+
+What do you mean in _certain_ frameworks.
+
+> _Just that in the original specification of MVC, directories weren't mentioned. Indeed, the original form of MVC is considerably more involved than what I just described; but that's a story for a different time._
+
+You mean there's more to MVC than just three directories and three types of objects?
+
+> _(chuckle) Oh, yes. Much, much, more. But that's for later._
+
+OK, so I'm starting to get the idea. If I say "Dependency Injection", everybody knows exactly what I mean. So I don't have to explain myself.
+
+> _Right. It saves a lot of time when designers all know the Design Patterns. They can just talk to each other using those names._
+
+OK, and if follow the form of the pattern, then everybody will know what to expect in the code.
+
+> _Right! By following the canonical form, you relieve everyone else of the work of having to decode what you have done. They recognize the form and can follow it easily._
+
+And you say there are a lot of these patterns?
+
+> _The Design Patterns book gives names and forms to twenty-three tried and true solutions to common software problems._
+
+Hmmm. And they're all as useful as MVC and DI?
+
+> _Some are much more useful than that!_
+
+Hmmm. I should probably learn them then.
+
+> _I would say so! Can you name one now?_
+
+Uh...
+
+> _Just one._
+
+Uh...
+
+> _Let me help you: Abstract Factory, Builder, Factory Method, Prototype, Singleton, Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy, Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, and Visitor._
+
+I think I've got some studying to do.
+
+> _Yes, I think you do._
+
+
+
+----
+[1] John Matthew Vlissides passed away on the 24th of November, 2005. He was a colleague and a friend. He came to my aid more than once. He is missed.
+
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.