Mastering JavaScript Design Patterns

Discover how to use JavaScript design patterns to create powerful applications with reliable and maintainable code

Mastering JavaScript Design Patterns

This ebook is included in a Mapt subscription
Simon Timms

1 customer reviews
Discover how to use JavaScript design patterns to create powerful applications with reliable and maintainable code
$0.00
$13.50
$44.99
$29.99p/m after trial
RRP $26.99
RRP $44.99
Subscription
eBook
Print + eBook
Start 30 Day Trial
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 
Preview in Mapt

Book Details

ISBN 139781783987986
Paperback290 pages

Book Description

Applying design patterns to JavaScript code creates more reliable and maintainable code. In this book, you will explore different design patterns and learn where and how to implement them with the help of detailed examples.

In the first part of the book, we start off with an introduction to design patterns, and then move on to creating classical structures that are used to organize code. Next, we look at the creational, structural, and behavioral patterns. The second part of the book dives into patterns used for functional programming, model view patterns, patterns to build web applications, and messaging patterns. A number of very interesting advanced JavaScript patterns such as dependency injection and live postprocessing are also covered.

By the end of this book, you will learn to identify places where a pattern would improve code readability and maintainability.

Table of Contents

Chapter 1: Designing for Fun and Profit
The road to JavaScript
What is a design pattern?
Antipatterns
Summary
Chapter 2: Organizing Code
Chunks of code
What's the matter with global scope anyway?
Objects in JavaScript
Build me a prototype
Inheritance
Modules
ECMAScript 6 classes and modules
Best practices and troubleshooting
Summary
Chapter 3: Creational Patterns
Abstract Factory
Implementation
Builder
Factory Method
Singleton
Prototype
Hints and tips
Summary
Chapter 4: Structural Patterns
Adapter
Bridge
Composite
Decorator
Façade
Flyweight
Proxy
Hints and tips
Summary
Chapter 5: Behavioral Patterns
Chain of responsibility
Command
Interpreter
Iterator
Mediator
Memento
Observer
State
Strategy
Template method
Visitor
Hints and tips
Summary
Chapter 6: Functional Programming
Functional functions are side-effect free
Function passing
Filters and pipes
Accumulators
Memoization
Immutability
Lazy instantiation
Hints and tips
Summary
Chapter 7: Model View Patterns
First, some history
Model View Controller
Model View Presenter
Model View ViewModel
Hints and tips
Summary
Chapter 8: Web Patterns
Sending JavaScript
Plugins
Doing two things at once – multithreading
The circuit breaker pattern
The promise pattern
Hints and tips
Summary
Chapter 9: Messaging Patterns
What's a message anyway?
Request-reply
Publish-subscribe
Dead-letter queues
Hints and tips
Summary
Chapter 10: Patterns for Testing
The testing pyramid
Test in the small with unit tests
Arrange-Act-Assert
Fake objects
Monkey patching
Interacting with the user interface
Build and test tools
Hints and tips
Summary
Chapter 11: Advanced Patterns
Dependency injection
Live postprocessing
Aspect-oriented programming
Macros
Hints and tips
Summary
Chapter 12: ES6 Solutions Today
TypeScript
Traceur
Hints and tips
Summary

What You Will Learn

  • Organize your code with classes and modules
  • Explore the original Gang of Four patterns and learn how to apply them to JavaScript
  • Decrease the degree of coupling in applications and increase code reuse through creational patterns
  • Rethink your coding through the use of functional patterns
  • Master advanced JavaScript patterns such as dependency injection and live postprocessing
  • Improve the testability of your code with mock objects, mocking frameworks, and monkey patching
  • Discover the patterns that are the basis of modern JavaScript libraries such as Knockout.js, Angular.js, and Backbone.js

Authors

Table of Contents

Chapter 1: Designing for Fun and Profit
The road to JavaScript
What is a design pattern?
Antipatterns
Summary
Chapter 2: Organizing Code
Chunks of code
What's the matter with global scope anyway?
Objects in JavaScript
Build me a prototype
Inheritance
Modules
ECMAScript 6 classes and modules
Best practices and troubleshooting
Summary
Chapter 3: Creational Patterns
Abstract Factory
Implementation
Builder
Factory Method
Singleton
Prototype
Hints and tips
Summary
Chapter 4: Structural Patterns
Adapter
Bridge
Composite
Decorator
Façade
Flyweight
Proxy
Hints and tips
Summary
Chapter 5: Behavioral Patterns
Chain of responsibility
Command
Interpreter
Iterator
Mediator
Memento
Observer
State
Strategy
Template method
Visitor
Hints and tips
Summary
Chapter 6: Functional Programming
Functional functions are side-effect free
Function passing
Filters and pipes
Accumulators
Memoization
Immutability
Lazy instantiation
Hints and tips
Summary
Chapter 7: Model View Patterns
First, some history
Model View Controller
Model View Presenter
Model View ViewModel
Hints and tips
Summary
Chapter 8: Web Patterns
Sending JavaScript
Plugins
Doing two things at once – multithreading
The circuit breaker pattern
The promise pattern
Hints and tips
Summary
Chapter 9: Messaging Patterns
What's a message anyway?
Request-reply
Publish-subscribe
Dead-letter queues
Hints and tips
Summary
Chapter 10: Patterns for Testing
The testing pyramid
Test in the small with unit tests
Arrange-Act-Assert
Fake objects
Monkey patching
Interacting with the user interface
Build and test tools
Hints and tips
Summary
Chapter 11: Advanced Patterns
Dependency injection
Live postprocessing
Aspect-oriented programming
Macros
Hints and tips
Summary
Chapter 12: ES6 Solutions Today
TypeScript
Traceur
Hints and tips
Summary

Book Details

ISBN 139781783987986
Paperback290 pages
Read More
From 1 reviews

Read More Reviews