Node.js Design Patterns
4.4 (69 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
419 students enrolled

Node.js Design Patterns

Write efficient and resilient Node.js applications using industry-standard software design patterns
4.4 (69 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
419 students enrolled
Created by Packt Publishing
Last updated 3/2019
English
English [Auto]
Current price: $86.99 Original price: $124.99 Discount: 30% off
5 hours left at this price!
30-Day Money-Back Guarantee
This course includes
  • 2.5 hours on-demand video
  • 1 downloadable resource
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
Training 5 or more people?

Get your team access to 4,000+ top Udemy courses anytime, anywhere.

Try Udemy for Business
What you'll learn
  • Understand the importance of learning and using industry-standard design patterns when writing Node .js apps
  • Learn more about core creational design patterns such as Singletons, Factory, and Builder patterns
  • Efficiently avoid callback hell and implement asynchronous behavior using Promises, Async/Await, and Generators
  • Develop a deeper understanding of the module system in Node .js and to implement patterns such as dependency injection
  • Get an insight into structural design patterns such as Proxy, Adapter, Decorator, and others that can help you create systematic, efficient relationships between objects and entities
  • Reuse well-known techniques to solve common design and coding issues
  • Understand the behavioral design patterns such as Strategy, Observers, Middleware, and even the Publisher-Subscriber pattern to craft efficient communication patterns between objects, processes, and even applications
Course content
Expand all 22 lectures 02:35:20
+ Core Design Patterns
5 lectures 30:20

This video will give you an overview about the course.

Preview 03:00

Software development is about solving problems effectively and a major part of this process is employing efficient coding practices. That is where the concept of design patterns comes into play. We will thus explore the purpose of design patterns and how they can help us solve problems effectively.

   •  Examine the etymology of design patterns as a concept

   •  Understand the core benefits of following a design pattern

   •  A quick glance at the flavor of design patterns that we will learn in this course

What Are Design Patterns?
03:52

When creating objects, especially in modularized applications such as Node.js apps, we often need a singular instance of an object to be available across all modules/functions. A Singleton helps us achieve that.

   •  Define a singleton and its purpose

   •  Examine the role of Node’s module system

   •  Implement the Singleton pattern using functions and classes in Node.js

Singletons
06:47

We should aim to define interfaces that allow the creation of pre-configured objects easily. The factory pattern helps us construct objects from a generic foundation by an interface that hides the implementation logic from the consumer.

   •  Define the factory pattern and its need through an example

   •  Implement the factory pattern in an example

   •  Examine and implement the abstract factory pattern

Factories – Generic Interface for Creating Objects
07:27

When writing reusable packages/classes, an easy to use interface that simplifies the construction of a complicated object is essential. The builder pattern allows you to implement a step by step process when creating complicated objects.

   •  Understand what a builder does and define the pattern

   •  Implement the builder pattern in a simple to understand example

   •  Implement the builder pattern when authoring classes

Building Object in Steps – Builder Design
09:14
+ Control Flow Patterns
4 lectures 25:11

When writing asynchronous code in Node.js, the default and fundamental pattern used is the callback pattern. There are, however, pitfalls to using this pattern at scale and complexity.

   •  Examine the callback pattern using an example

   •  Know more about callback hell

   •  Examine a callback hell situation using example code

Preview 04:38

To prevent callback hell, we can use promises which results in cleaner and manageable asynchronous code.

   •  Define promises and its workings

   •  Know how promises can help us write cleaner code

   •  Implement promises in a Node.js application

Using Promises
07:26

While promises help us write cleaner asynchronous code, the async/await pattern further simplifies this pattern by letting you write synchronous style code.

   •  Define the async/await pattern and its synchronous style execution pattern

   •  Handle multiple asynchronous methods using async/await

   •  Examine the async/await pattern using an example

Using Async/Await
05:37

A generator function produces an iterator and allows you to pause and resume execution. This allows you to implement controlled iteration which can be incredibly useful for tasks like paging.

   •  Understand the difference between regular functions and generators

   •  Explore the anatomy of a generator function and async generators

   •  Implement generators and async generators in code

Generators
07:30
+ Module Design Patterns
2 lectures 11:30

Writing modular code is at the heart of Node.js applications. At its core, it implements the revealing module pattern. We can also implement this pattern when using ES6 classes.

   •  Examine the Node.js module system and the issue of scope

   •  Understand the revealing module pattern in Node.js

   •  Implement the revealing module pattern effectively when using ES6 classes

Preview 04:56

Node.js apps are made up of multiple dependencies. Hard wiring and tightly coupled dependencies can result in a lot of refactoring. The dependency injection pattern helps us write decoupled code.

   •  Understand the issues with tightly coupled dependencies

   •  Examine the dependency injection pattern as a solution to tight cohesion

   •  Implement the dependency injection pattern in a Node.js app

Dependency Injection
06:34
+ Structural Design Patterns
4 lectures 33:46

There is often a need to introduce a virtualization layer between an object and a consumer, without introducing changes to the interface. This is where the proxy pattern is particularly useful.

   •  Examine the proxy pattern and understand its typical use cases

   •  Implement the pattern using composable wrappers with the proxy API

   •  Implement the proxy for encrypting data and creating an observable object

Proxy
08:51

When designing interfaces that have to work with another interface, we often need to bridge the differences in implementation without causing major code refactoring. The adapter pattern helps us achieve this result.

   •  Examine the pattern and its application as a bridge between two interfaces

   •  Examine a scenario where a change of database engine introduces API incompatibilities

   •  Implement an adapter to solve the incompatibilities

Adapter Pattern
07:19

When an object needs to be augmented with additional capabilities, the usual route is to subclass. However, when subclasses are not an option, decorators can be used to dynamically add features.

   •  Examine the pattern and how it can empower an object

   •  Examine decorators for functions as a higher order function

   •  Implement the TC39 proposed decorator syntax for classes

Decorator
09:16

Designing hierarchical trees of objects which stem from a base class can be tough. The composite pattern comes to rescue and allows you to create leaf nodes and collections of leaves that implement a common interface.

   •  Examine the composite pattern and its elements

   •  Learn the need for a uniform interface across entities and collection of entities

   •  Implement the composite pattern in a Node.js

Composite
08:20
+ Behavioral Design Patterns
5 lectures 36:44

When you want to maintain a uniform interface and still be able to offer multiple flavors of algorithms, the strategy design pattern comes to rescue.

   •  Examine the strategy pattern and its use

   •  Understand the constituents of the strategy pattern

   •  Implement the strategy pattern in a hypothetical payment gateway

Strategy
06:22

Designing a uniform interface that helps invoke commands can be hard, especially when every command is implemented uniquely. The command design pattern helps us write a diverse set of operations, without affecting or refactoring the invocation interface.

   •  Understand the need for the command pattern

   •  Examine the internals of the command pattern

   •  Implement the command pattern in a command line blog app

Command
10:29

When designing systems that should react to changes in an object, you can implement the observer pattern. This pattern allows you to observe state changes and implement one or more dependencies that are notified automatically.

   •  Examine the observer pattern and compare its benefits with the callback pattern

   •  Understand the event emitter interface in Node.js

   •  Implement the observer pattern using the event emitter interface

Observers
08:04

When an incoming request or data needs to be augmented/modified before it actually is consumed by the target object, a series of intermediary functions can be designed. The middleware pattern helps us implement such a pipeline of functions easily.

   •  Understand the need for the middleware pattern

   •  Explore the role of a middleware manager and use cases

   •  Create a middleware manager in Node.js

Middleware
07:18

Designing uniform interfaces when the internal implementation varies, is always a challenge and we’ve seen how patterns like strategy can help us streamline the process. The template pattern also helps us build a uniform interface when internal implementations are bound to vary by usage.

   •  Understand the template pattern and its constituents

   •  Learn the role of the abstract class and template methods

   •  Implement the template method pattern in an app

Template
04:31
+ Messaging Patterns
2 lectures 17:49

When multiple clients need to request data from a server or a resource, the request-reply pattern is the right choice to do the job.

   •  Understand the request – reply pattern.

   •  Examine the role of the correlation identifier.

   •  Implement the request and reply pattern in a simple Node.js app.

Request – Reply
08:23

When multiple services need to communicate with each other, or when two isolated mediums want to share data, or when a source needs to publish data for multiple independent consumers, the publisher – subscriber pattern is a great solution.

   •  Understand the publisher-subscriber pattern and its use cases.

   •  Study the role of a message broker as a unifying medium.

   •  Demonstrate the use of a message broker and the publisher – subscriber pattern.

Publisher – Subscriber
09:26
Requirements
  • The intended audience is expected to have basic knowledge of Node .js and the ecosystem, good command over JavaScript, and intermediate working skills on Linux/MacOS.
Description

When writing Node.js applications, it’s absolutely imperative that we employ battle-tested guidelines that can help us write efficient and resilient code. These guidelines are known as design patterns. Design patterns are an important part of software development and are a proven way of solving a given problem.

In this course, you’ll take a comprehensive look at industry-standard design patterns, identify challenges that you would commonly encounter while designing and developing software, and implement solutions in Node.js applications. The efficacy of these patterns has been proven over time and a lot of these standard patterns can be implemented when writing JavaScript apps with Node.js.

By implementing design patterns, you can write code that is crafted for efficiency and reusability and is resilient against errors and typical pitfalls that result from poorly written code.

This course uses Node.js 10.8.0, and JavaScript ES8, while not the latest version available, it provides relevant and informative content for legacy users of Node.js, and JavaScript.

About the Author

Sachin Bhatnagar began dabbling with Computer Programming and graphics at the age of 14 on a Sinclair ZX Spectrum that ran the BASIC programming language.

During the early 2000s, Sachin forayed into Computer Graphics and Visual Effects training and production. From developing world-class curricula to imparting training to over five thousand students in the classroom and over twenty-five thousand online, Sachin has actively contributed to fueling innovation, creating brand identities, and crafting innovative software solutions for corporate companies and individuals alike.

He has also worked with one of India’s leading media and entertainment training companies as a vice president. Having said all this, Sachin's first love is coding and he strongly emphasizes its importance to one and all. His passion for education and love for coding has culminated in several courses on technology. His expertise lies in JavaScript, Node.js, Vue.js, Chatbots, and the list keeps growing all the time.

Who this course is for:
  • This course is for developers and software architects with a basic working knowledge of JavaScript who are interested in acquiring a deeper understanding of how to design and develop enterprise-level Node .js applications.