Book description
As a web developer, you'll already know that JavaScript is a powerful language, allowing you to add an impressive array of dynamic functionality to otherwise static web sites. But there is more power waiting to be unlocked—JavaScript is capable of full object–oriented capabilities, and by applying object-oriented principles, best practices, and design patterns to your code, you can make it more powerful, more efficient, and easier to work with alone or as part of a team.
With Pro JavaScript Design Patterns, you'll start with the basics of object–oriented programming in JavaScript applicable to design patterns, including making JavaScript more expressive, inheritance, encapsulation, information hiding, and more. With that covered, you can kick–start your JavaScript development in the second part of the book, where you'll find detail on how to implement and take advantage of several design patterns in JavaScript, including composites, decorators, façades, adapters, and many more.
Each chapter is packed with real–world examples of how the design patterns are best used and expert advice on writing better code, as well as what to watch out for. Along the way you'll discover how to create your own libraries and APIs for even more efficient coding.
Master the basics of object–oriented programming in JavaScript, as they apply to design patterns
Apply design patterns to your kick–start your JavaScript development
Work through several real–world examples
Table of contents
- Title Page
- Dedication
- Contents at a Glance
- Contents
- About the Authors
- About the Technical Reviewer
- Acknowledgments
- Introduction
-
PART 1: Object-Oriented JavaScript
- CHAPTER 1: Expressive JavaScript
- CHAPTER 2: Interfaces
- CHAPTER 3: Encapsulation and Information Hiding
- CHAPTER 4: Inheritance
-
CHAPTER 5: The Singleton Pattern
- The Basic Structure of the Singleton
- Namespacing
- A Singleton As a Wrapper for Page-Specific Code
- A Singleton with Private Members
- Lazy Instantiation
- Branching
- Example: Creating XHR Objects with Branching
- When Should the Singleton Pattern Be Used?
- Benefits of the Singleton Pattern
- Drawbacks of the Singleton Pattern
- Summary
- CHAPTER 6: Chaining
-
PART 2: Design Patterns
- CHAPTER 7: The Factory Pattern
- CHAPTER 8: The Bridge Pattern
- CHAPTER 9: The Composite Pattern
-
CHAPTER 10: The Facade Pattern
- Some Facade Functions You Probably Already Know About
- JavaScript Libraries As Facades
- Facades As Convenient Methods
- Example: Setting Styles on HTML Elements
- Example: Creating an Event Utility
- General Steps for Implementing the Facade Pattern
- When Should the Facade Pattern Be Used?
- Benefits of the Facade Pattern
- Drawbacks of the Facade Pattern
- Summary
- CHAPTER 11: The Adapter Pattern
- CHAPTER 12: The Decorator Pattern
-
CHAPTER 13: The Flyweight Pattern
- The Structure of the Flyweight
- Example: Car Registrations
- Managing Extrinsic State
- Example: Web Calendar
- Example: Tooltip Objects
- Storing Instances for Later Reuse
- When Should the Flyweight Pattern Be Used?
- General Steps for Implementing the Flyweight Pattern
- Benefits of the Flyweight Pattern
- Drawbacks of the Flyweight Pattern
- Summary
- CHAPTER 14: The Proxy Pattern
- CHAPTER 15: The Observer Pattern
- CHAPTER 16: The Command Pattern
-
CHAPTER 17: The Chain of Responsibility Pattern
- The Structure of the Chain of Responsibility
- Passing on Requests
- Implementing a Chain of Responsibility in an Existing Hierarchy
- Event Delegation
- When Should the Chain of Responsibility Pattern Be Used?
- Example: Image Gallery Revisited
- Benefits of the Chain of Responsibility Pattern
- Drawbacks of the Chain of Responsibility Pattern
- Summary
- Index
Product information
- Title: Pro JavaScript™ Design Patterns
- Author(s):
- Release date: December 2007
- Publisher(s): Apress
- ISBN: 9781590599082
You might also like
book
Architecting CSS: The Programmer’s Guide to Effective Style Sheets
Leverage various CSS features in combination with popular architectures in order to bring your style sheets …
book
Object-Oriented JavaScript - Third Edition
Learn everything you need to know about object-oriented JavaScript with this comprehensive guide. Enter the world …
article
Run Llama-2 Models Locally with llama.cpp
Llama is Meta’s answer to the growing demand for LLMs. Unlike its well-known technological relative, ChatGPT, …
book
Mastering JavaScript Design Patterns - Second Edition
Write reliable code to create powerful applications by mastering advanced JavaScript design patterns About This Book …