Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
Let's explore the origins of design patterns.
Learn more
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Hello, I'm Craig and I'm a developer.
0:04
In this course,
0:07
we'll explore the wonderful world
of software design patterns.
0:08
You'll learn what they are,
where they come from, and
0:11
why you should be familiar with them.
0:13
This course is going to be taught in a way
that's programming language that agnostic.
0:16
In other words, no matter what language
you use, whether it be Java, Python,
0:19
Swift, PHP,
0:23
JavaScript, I'll explain design
patterns using a shared terminology.
0:24
Design patterns really are for
everyone, and
0:28
I'm super excited to help
you to get to know them.
0:29
Now before we get started,
let's go over some quick ground rules.
0:33
First there are speed
controls on the video player.
0:36
You should feel free
to slow me way down or
0:39
speed me up, and
I won't be offended at all.
0:42
Second there are detailed teachers notes
accompanying most of these videos videos.
0:45
Now I attempt to keep the notes up
to date by answering your questions.
0:49
So make a habit of checking them out.
0:52
There's a good chance that you'll
have the answer you're looking for
0:54
sitting right there in the notes.
0:56
Now if you don't find
your answer in my notes,
0:58
the Treehouse community is
the next place to turn.
1:01
Please, please, please ask questions.
1:04
I guarantee you aren't the only one
wondering what you're wondering.
1:07
And by sharing, everyone wins.
1:11
The community is extremely welcoming and
responsive so
1:13
you have absolutely nothing
to lose by participating.
1:16
All right, let's take a quick swing at
breaking down what a design pattern
1:20
actually is.
1:24
We developers build all sorts of
software to solve many different types
1:25
of problems, right?
1:28
Although our projects might be completely
different from a business perspective,
1:30
you know, you might be running
a social media dating website, and
1:34
I might be writing code that
makes robots break dance.
1:37
Despite those differences,
1:40
we as developers run into similar
problems crafting or designing our code.
1:41
Now, don't confuse the word design
with the actual aesthetic, you know,
1:46
the look and feel.
1:50
I'm talking about how we
structure our applications code.
1:51
Wouldn't it be great if there was a place
to find the best practice when you run
1:55
into one of those design conundrums?
1:58
Well, that is exactly where
design patterns come in.
2:01
A pattern is a solution to
a problem in a context, so
2:04
this is the common definition given for
one of these patterns.
2:09
It's not the most helpful is it?
2:11
It's pretty broad definition.
2:13
Right?
2:15
Let's talk about why.
2:16
So the concept of having a defined
pattern that provides a solution
2:18
to a recurring problem
in a specific context.
2:22
Well, that comes from a totally different
profession than software development.
2:24
Design patterns actually come
from the architecture world.
2:27
You know like the designers of
buildings and public spaces.
2:31
In the late 1970s an architect
named Christopher Alexander
2:34
began exploring the possibility of
providing a reference of proven ideas for
2:38
constructing a living and
working environment.
2:42
The name of this book was called
a Pattern Language, and it contained
2:44
over 250 patterns that tackled all
sorts of architecting problems.
2:48
The patterns vary from
designing a place for
2:52
waiting and this could be applied to like
a bus stop or a hospital waiting room.
2:54
To patterns on how to maximize
sunlight in a room and
2:58
the problems that that
extra sun might introduce.
3:01
The idea here again is to produce
a catalog of well defined
3:04
improvement to work ideas for
problems in a specific context.
3:08
In other words, architects didn't have to
come up with their own solution to each
3:12
problem that they encountered,
3:15
they had a catalog of a ready made
solutions of patterns that they could use.
3:16
And that's a pretty powerful concept.
3:21
So powerful, in fact, that it caught
the eyes of some software engineers.
3:24
And those engineers, knowing that
all developers could benefit from
3:28
documenting well thought out solutions to
the common problems that we all encounter
3:32
attempted to use the same
pattern structure.
3:36
And it worked pretty well.
3:38
So they started creating more patterns.
3:40
They shared their thoughts
at conferences and more and
3:42
more developers grew
interested in the concept.
3:44
Soon the patterns proved useful in solving
similar problems across diverse context,
3:47
and they caught on like wildfire.
3:52
In an effort to capture
these emerging patterns for
3:54
software engineers wrote
a book to catalog them.
3:57
This book has been incredibly influential
in the craft of software development and
3:59
more specifically object oriented design.
4:04
This book is one of a handful that almost
every developer has encountered at some
4:06
point in their career.
4:10
The four authors have been
nicknamed the gang of four.
4:12
Now, because of the book's
super long title, this is
4:15
often shortened to the gang of four book,
and because we programmers are often known
4:18
to shorten things to extremes,
you'll often see this referred to as GoF.
4:23
The Gang of Four book was published
in 1994, more than two decades ago.
4:27
But the 23 design patterns that it
introduced are still very much alive and
4:33
used in so many libraries and
4:37
frameworks that you probably interact
with them every single time you code.
4:39
The book was written based on
the programming languages of C++ and
4:44
Smalltalk.
4:47
But the patterns apply to all
object oriented languages.
4:48
The design patterns in this book are
descriptions of communicating objects and
4:52
classes that are customized to
solve a general design problem
4:56
in a particular context.
4:59
The book does a great job of further
specifying our original design pattern
5:01
definition.
5:05
Some languages approach object oriented
programming in different ways and
5:06
use different terms, for
5:10
example, classes are part of a typical
JavaScript programmer's vocabulary.
5:11
If you're coming from a JavaScript
background, you can think of a class
5:15
kinda like a JavaScript object
with properties and methods.
5:18
Now there's a bit more classes than that,
but that description should work for
5:21
this workshop.
5:25
Check the teacher's notes for more.
5:26
Newer design patterns have emerged
in the past two decades, and
5:28
some of the original patterns
have even been written
5:31
directly into the programming
languages as they evolve.
5:34
There are many different programming
design patterns, and they all have names
5:37
like Singleton, Adapter, Observer and
Mediator, and that's just to name a few.
5:40
In this workshop, I'll introduce you to
some of the most commonly used patterns.
5:45
In the next video, I'll show you why it's
pretty much a necessity to be just a wee
5:49
bit familiar with them.
5:53
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up