Unlimited WordPress themes, graphics, videos & courses! Unlimited asset downloads! From $16.50/m

Next lesson playing in 5 seconds

  • Overview
  • Transcript

1.1 Introduction

Welcome to JavaScript Design Patterns. In this introductory lesson we'll take a look at what a design pattern is, what it is not, and why design patterns can be so useful. We'll also discuss the benefits of using patterns, as well as some problems with patterns.

1.1 Introduction

Hi folks, welcome to Put JavaScript Design Patterns into Practice. My name is Dan Wellman, and over this course we're going to learn about some design patterns that you commonly see or make use of when developing applications in JavaScript. This course is aimed at those with some JavaScript familiarity and experience already. If you're interested in the subject design patterns I'm going to assume that you have some knowledge of object oriented programming to, but don't worry all concepts used in the course will be explained in full. If you don't want to follow along with the code examples, you can just grab the source code for the whole course from GitHub and skip straight to lesson 2.1. So first of all, what exactly do I mean by design pattern? What is a design pattern? Quite simply, a design pattern is a proven solution to a common problem in software development. Patterns are a way to adhere to good design principles and can help create maintainable code that can be worked on by teams. A design pattern is not a specific piece of code, it can't be copied and pasted into place and just work. The same pattern can be implemented in different ways depending on the situation, context, and language in use. As well as being solutions to common programming problems, design patterns are also a way for teams to communicate about the design of an application. Patterns are a language that can be used to convey ideas and facilitate discussions. Historically, design patterns became popularized in software development by a book written in the early 90s by four guys known as the Gang of Four. Their book contains 23 reusable patterns that could be applied to specific situations. Since then, further patterns have arisen and the existing patterns have been adapted for newer languages. Some patterns aren't relevant in some languages. One example of this is the prototype pattern. In JavaScript we don't really need to worry about implementing the prototype pattern because it's built into the language. One example of the pattern very common to JavaScript is the module pattern which wasn't one of the original 23 patterns by the way. We won't be looking at this pattern in this course, so let's just use it as an example now. The problem here is the global scope. We need a way to shield our code from the global scope. The module pattern solves this problem by wrapping up code inside closures and specifying what is returned from the module. One point I want to mention is that it's very difficult to talk about design patterns without referring to object-oriented concepts such as classes. JavaScript doesn't have classes and classes aren't required to use patterns in JavaScript, but it just makes it easier to explain things using concepts like base class. So throughout the remainder of this course, when I talk about classes I mean the JavaScript emulation of classes. So let's move on to the next lesson now and get our development area set up and ready to use. Thanks for watching.

Back to the top