Mastering JavaScript Design Patterns: Building Better Apps

A practical introduction to writing better and more maintainable code using JavaScript design patterns
2.7 (21 ratings) Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
400 students enrolled
$19
$95
80% off
Take This Course
  • Lectures 38
  • Length 2 hours
  • Skill Level Intermediate Level
  • Languages English, captions
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion
Wishlisted Wishlist

How taking a course works

Discover

Find online courses made by experts from around the world.

Learn

Take your courses with you and learn anywhere, anytime.

Master

Learn and practice real-world skills and achieve your goals.

About This Course

Published 10/2015 English Closed captions available

Course Description

As the language of the web, JavaScript is used prolifically by developers building new applications every day. However, some developers still lack the knowledge about how to write things in a simpler, clearer and more maintainable way. Design patterns are proven solutions to common development problems, and can boost code quality and application maintainability, as well as improve developer efficiency.

Mastering JavaScript Design Patterns demonstrates how to apply design patterns in real life situations, whether that's for new, or already existing projects. It will help you to make your applications more flexible, perform better, and easier to maintain.

We’ll begin by building a simple music player application, and then we’ll build and add more and more functionality to our music player application. We’ll also cover different ways to modularize the application.

In the next two sections we’ll build a server and will load data from it. We’ll cover different techniques for caching, fallbacks, optimizing memory consumption and deferred actions.

In the last section we’ll cover code maintainability improvement techniques by using less known, yet powerful JavaScript techniques.

About The Author

Alexandr Truhin (bumbu) is a proponent of open web and robust solutions. His engineering background is based on desktop, back-end and front-end web applications where most recent years he’s using JavaScript to build fast and reach web applications.

His passion is improving and passing knowledge which has been doing by teaching in University, writing blog posts, mentoring other developers and contributing to open source community.

What are the requirements?

  • This video course demonstrates the fundamentals of JavaScript design patterns through the practical development of an application, a music player. Each pattern will be exemplified and explained. Unlike many other guides this one is heavily practical, featuring bite sized chunks of information, detailed explanations, and real results.

What am I going to get from this course?

  • Understand how to build a practical application with the help of design patterns
  • Write robust, maintainable JavaScript applications by using battle-tested solutions to common problems
  • Improve code readability by using common solutions and better names for what you are trying to accomplish
  • Build and use a server as a data provider
  • Leverage the deferred nature of JavaScript with call-backs and promises
  • Better your communication of design goals with other programmers through usage of common terms
  • Create a separation of concerns to split modules based on different responsibilities.

What is the target audience?

  • You will get the most out of this course if you have at least some experience with JavaScript. But even if you've been writing JavaScript for several years you may find many interesting and useful techniques. By the end of this course you’ll be able to apply many best practices for developing JavaScript applications that are robust, readable, and easy to maintain.

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.

Curriculum

Section 1: Introduction
03:01

Introduction of all the sections of the course.

02:44

Understand what a design pattern is and why it is important to know them.

02:51

How patterns are different in JavaScript? Different versions of ECMAScript used in this course.

Section 2: Starting the Project
05:30

Rendering the tracks list.

03:56

Adding play functionality to the player.

02:43

Hide the specifics of components by encapsulating information into modules.

04:26

Browsers represent complex systems. In order to simplify their use, a facade pattern can be used.

01:25

Use adapter pattern to simplify the usage of setInterval and setTimeout functions.

02:29

Sometimes, there are alternative ways to match for conditions.

Section 3: Modularizing the Application
04:29

The application grew quite a bit, so it has become hard to manage it. Separating it into smaller modules will make it more manageable.

04:10

The Namespace pattern exposes modules through a global variable and does not resolve dependencies.

04:59

It is hard to establish a communication between modules using classical methods. We’ll use PubSub for communication between modules.

04:51

A new standard was established for defining and using modules - that is, ECMAScript 6 modules.

Section 4: Organizing the Application Through Separation of Concerns
04:22

Make the application more robust by decoupling tracks queue from tracks player.

07:20

Treating each track as a separate component will allow an easier separation of concerns.

02:24

In MVC, communication between model and view happens through a PubSub pattern.

04:21

MVC is one of the most used patterns that separates the internal representation of information from the UI with which user interacts.

03:06

MVP is another commonly used pattern that is used to organize the UI elements.

04:20

Often, before being rendered, model data has to formatted. For such cases, patterns such as MVVM are used.

Section 5: Enhancing the Tracks Functionality and Adding Nested Tracks
03:09

We'll add multiple types of tracks and we'll use Factory pattern to create them. Also we'll implement lazy initialization that will defer initialization of objects until they are necessary.

03:14

Track removal was not implemented. In this video we'll do that. Also we'll add methods chaining

02:45

The collection should be the only entity that manages its state. Thus, we'll move the collection iteration logic into the collection module.

02:50

Generators are powerful but have a limited set of functionality. An alternative to generators are iterators that use the same iteration protocol.

02:45

We'll add nested tracks. As each track can be both a parent and a child, we'll use the Composite pattern to make adding of nested tracks work.

04:38

After adding nested tracks, only their rendering worked as expected. Play and remove functionality worked in a wrong way. We'll fix that using an iterator that works with nested iterators.

Section 6: Building the Server and Loading Data from It
02:17

Storing the data in application code is a bad practice. We’ll defer that to the server.

03:57

Server will return a list of parent tracks, where child tracks would be embedded into parent tracks.

02:31

AJAX requests are asynchronous. This requires that you use callbacks in order to continue application execution only after the data becomes available.

01:40

Callbacks often lead to a complex code. Also, managing errors has to be done in each callback. Promises help to overcome these complications.

01:33

Passing context scope into callbacks may lead to bugs. A much cleaner approach is to find callbacks to certain contexts.

Section 7: Loading Tracks' Additional Data
04:27

Until now, we loaded only main data about track. Now, we need more data about each track. So, on track play, we’ll ask the server for more data about active track.

01:53

Making the same request multiple times is inefficient. We'll optimize this by implementing a caching mechanism.

03:07

Relying on a single source of data is fault-prone. We’ll implement a mechanism that will allow us to use multiple sources for tracks' additional data.

02:43

Having multiple objects consumes memory. In case of objects that have many similar attributes, a Flyweight pattern can be used to decrease memory footprint by using shared objects with data.

Section 8: Improving Code Maintainability
04:16

We’ll use the Template method pattern that will allow to have an object with main functionality and subclassed objects with a specific functionality.

01:56

We'll use inversion of control that is a widely used pattern in applications with tests.

03:02

JavaScript live post-processing is a feature that may be used to validate, log, or even update arguments passed into functions.

03:38

We'll enable tracks’ models to support any string as attribute name.

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

Packt Publishing, Tech Knowledge in Motion

Over the past ten years Packt Publishing has developed an extensive catalogue of over 2000 books, e-books and video courses aimed at keeping IT professionals ahead of the technology curve. From new takes on established technologies through to the latest guides on emerging platforms, topics and trends – Packt's focus has always been on giving our customers the working knowledge they need to get the job done. Our Udemy courses continue this tradition, bringing you comprehensive yet concise video courses straight from the experts.

Ready to start learning?
Take This Course