Mastering JavaScript Design Patterns

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

Mastering JavaScript Design Patterns

Mastering
Simon Timms

Discover how to use JavaScript design patterns to create powerful applications with reliable and maintainable code
$26.99
$44.99
RRP $26.99
RRP $44.99
eBook
Print + eBook
$12.99 p/month

Get Access

Get Unlimited Access to every Packt eBook and Video course

Enjoy full and instant access to over 3000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

+ Collection
Free Sample

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: 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 2: Creational Patterns
Abstract Factory
Implementation
Builder
Factory Method
Singleton
Prototype
Hints and tips
Summary
Chapter 3: Structural Patterns
Adapter
Bridge
Composite
Decorator
FaΓ§ade
Flyweight
Proxy
Hints and tips
Summary
Chapter 4: Behavioral Patterns
Chain of responsibility
Command
Interpreter
Iterator
Mediator
Memento
Observer
State
Strategy
Template method
Visitor
Hints and tips
Summary
Chapter 5: Functional Programming
Functional functions are side-effect free
Function passing
Filters and pipes
Accumulators
Memoization
Immutability
Lazy instantiation
Hints and tips
Summary
Chapter 6: Model View Patterns
First, some history
Model View Controller
Model View Presenter
Model View ViewModel
Hints and tips
Summary
Chapter 7: Web Patterns
Sending JavaScript
Plugins
Doing two things at once – multithreading
The circuit breaker pattern
The promise pattern
Hints and tips
Summary
Chapter 8: Messaging Patterns
What's a message anyway?
Request-reply
Publish-subscribe
Dead-letter queues
Hints and tips
Summary
Chapter 9: 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 10: Advanced Patterns
Dependency injection
Live postprocessing
Aspect-oriented programming
Macros
Hints and tips
Summary
Chapter 11: 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: 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 2: Creational Patterns
Abstract Factory
Implementation
Builder
Factory Method
Singleton
Prototype
Hints and tips
Summary
Chapter 3: Structural Patterns
Adapter
Bridge
Composite
Decorator
FaΓ§ade
Flyweight
Proxy
Hints and tips
Summary
Chapter 4: Behavioral Patterns
Chain of responsibility
Command
Interpreter
Iterator
Mediator
Memento
Observer
State
Strategy
Template method
Visitor
Hints and tips
Summary
Chapter 5: Functional Programming
Functional functions are side-effect free
Function passing
Filters and pipes
Accumulators
Memoization
Immutability
Lazy instantiation
Hints and tips
Summary
Chapter 6: Model View Patterns
First, some history
Model View Controller
Model View Presenter
Model View ViewModel
Hints and tips
Summary
Chapter 7: Web Patterns
Sending JavaScript
Plugins
Doing two things at once – multithreading
The circuit breaker pattern
The promise pattern
Hints and tips
Summary
Chapter 8: Messaging Patterns
What's a message anyway?
Request-reply
Publish-subscribe
Dead-letter queues
Hints and tips
Summary
Chapter 9: 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 10: Advanced Patterns
Dependency injection
Live postprocessing
Aspect-oriented programming
Macros
Hints and tips
Summary
Chapter 11: ES6 Solutions Today
TypeScript
Traceur
Hints and tips
Summary

Book Details

ISBN 139781783987986
Paperback290 pages
Read More