Book Image

Mastering JavaScript Design Patterns - Second Edition

By : Simon Timms
Book Image

Mastering JavaScript Design Patterns - Second Edition

By: Simon Timms

Overview of this book

With the recent release of ES-2015, there are several new object-oriented features and functions introduced in JavaScript. These new features enhance the capabilities of JavaScript to utilize design patterns and software design methodologies to write powerful code. Through this book, you will explore how design patterns can help you improve and organize your JavaScript code. You’ll get to grips with creational, structural and behavioral patterns as you discover how to put them to work in different scenarios. Then, you'll get a deeper look at patterns used in functional programming, as well as model view patterns and patterns to build web applications. This updated edition will also delve into reactive design patterns and microservices as they are a growing phenomenon in the world of web development. You will also find patterns to improve the testability of your code using mock objects, mocking frameworks, and monkey patching. We’ll also show you some advanced patterns including dependency injection and live post processing. By the end of the book, you'll be saved of a lot of trial and error and developmental headaches, and you will be on the road to becoming a JavaScript expert.
Table of Contents (5 chapters)

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "You'll notice that we explicitly define the name field."

A block of code is set as follows:

let Castle = function(name){
 this.name = name;
}
Castle.prototype.build = function(){ console.log(this.name);}
let instance1 = new Castle("Winterfell");
instance1.build();

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

let Castle = function(name){
 this.name = name;
}
Castle.prototype.build = function(){ console.log(this.name);}
let instance1 = new Castle("Winterfell");
instance1.build();

Any command-line input or output is written as follows:

ls -1| cut -d \. -f 2 -s | sort |uniq

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "To access them there is a menu item, which is located under Tools | Developer Tools in Chrome | Tools | Web Developer in Firefox."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.