0% found this document useful (0 votes)
16 views

Pro JavaScript Design Patterns 1st Edition Ross Harmes instant download

The document provides links to download various design pattern books, including 'Pro JavaScript Design Patterns' by Ross Harmes and Dustin Diaz. It emphasizes the importance of object-oriented design principles in JavaScript and offers insights into implementing common software patterns. The book aims to enhance the skills of programmers by teaching them effective techniques for building maintainable and collaborative web applications.

Uploaded by

oredyyaniek
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Pro JavaScript Design Patterns 1st Edition Ross Harmes instant download

The document provides links to download various design pattern books, including 'Pro JavaScript Design Patterns' by Ross Harmes and Dustin Diaz. It emphasizes the importance of object-oriented design principles in JavaScript and offers insights into implementing common software patterns. The book aims to enhance the skills of programmers by teaching them effective techniques for building maintainable and collaborative web applications.

Uploaded by

oredyyaniek
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 61

Pro JavaScript Design Patterns 1st Edition Ross

Harmes pdf download

https://ebookfinal.com/download/pro-javascript-design-
patterns-1st-edition-ross-harmes/

Explore and download more ebooks or textbooks


at ebookfinal.com
We believe these products will be a great fit for you. Click
the link to download now, or visit ebookfinal
to discover even more!

Pro JavaScript Techniques 2nd Edition John Resig

https://ebookfinal.com/download/pro-javascript-techniques-2nd-edition-
john-resig/

Scala Design Patterns 1st Edition Nikolov

https://ebookfinal.com/download/scala-design-patterns-1st-edition-
nikolov/

Elemental Design Patterns 1st Edition Jason Mcc. Smith

https://ebookfinal.com/download/elemental-design-patterns-1st-edition-
jason-mcc-smith/

Head First Design Patterns 1st Edition Eric Freeman

https://ebookfinal.com/download/head-first-design-patterns-1st-
edition-eric-freeman/
Java Design Patterns 1st Edition Mr. Devendra Singh

https://ebookfinal.com/download/java-design-patterns-1st-edition-mr-
devendra-singh/

The Basics of Permaculture Design Ross Mars

https://ebookfinal.com/download/the-basics-of-permaculture-design-
ross-mars/

C 3 0 Design Patterns 1st Edition Judith Bishop

https://ebookfinal.com/download/c-3-0-design-patterns-1st-edition-
judith-bishop/

Advanced ActionScript 3 2nd Edition Design Patterns Ben


Smith

https://ebookfinal.com/download/advanced-actionscript-3-2nd-edition-
design-patterns-ben-smith/

Ontology Representation Design Patterns and Ontologies


That Make Sense 1st Edition R. Hoekstra

https://ebookfinal.com/download/ontology-representation-design-
patterns-and-ontologies-that-make-sense-1st-edition-r-hoekstra/
Pro JavaScript Design Patterns 1st Edition Ross Harmes
Digital Instant Download
Author(s): Ross Harmes; Dustin Diaz
ISBN(s): 9781590599082, 159059908X
Edition: 1
File Details: PDF, 2.46 MB
Year: 2008
Language: english
 CYAN  YELLOW
 MAGENTA BLACK
 PANTONE 123 C

Books for professionals by professionals ® The EXPERT’s VOIce ® in Web Development


Companion
eBook
Available

Pro JavaScript Design Patterns ™

Pro JavaScript Design Patterns


Dear Reader,

Pro
Web programming is becoming more complex and collaborative each day. A
new JavaScript™ library is born each week, and we are getting closer to the time
when web applications can seamlessly replace those found on our desktops. It
is no longer possible to design the behavior of your sites haphazardly without
thinking about long-term software maintainability.

JavaScript
The JavaScript language has matured. We have reached a point where soft-
ware development techniques once considered useful only in languages such
as Java and C++ are being applied to web programming. Therefore, we felt the

time has come for a book that explores object-oriented design principles and
applies them to the JavaScript language. The techniques needed to implement
patterns like factory, singleton, observer, composite, and facade in JavaScript
are easily understood, but they have not previously been discussed in depth in
a single book. We wanted to show programmers that JavaScript contains features

Design Patterns
on par with other high-level languages and is an object-oriented programming
language in its own right. In fact, we wrote the book that we ourselves have always


wanted to read.
In this book, we will teach you about commonly used software patterns for
designing the code that drives your websites and applications. You will learn
object-oriented JavaScript programming, starting with routine tasks and pro-
gressing to advanced techniques and patterns. We will help you create libraries
and APIs that can be used by others, as well as show you techniques that will
help you interact with other JavaScript programmers and work effectively in
large teams. Most of all, we will show you how powerful, expressive, and flexible
the JavaScript language can be.

Ross Harmes and Dustin Diaz


The essentials of object-oriented
JavaScript™ programming
Companion eBook Related Titles

See last page for details


on $10 eBook version

SOURCE CODE ONLINE


www.apress.com
ISBN-13: 978-1-59059-908-2
ISBN-10: 1-59059-908-X Harmes,
Diaz
Ross Harmes and Dustin Diaz
54499

US $44.99

Shelve in
Web development

User level:
9 781590 599082
Intermediate–Advanced

this print for content only—size & color not accurate spine = 0.693" 296 page count
908Xch00FM.qxd 11/16/07 1:05 PM Page i


Pro JavaScript
Design Patterns

Ross Harmes and Dustin Diaz


908Xch00FM.qxd 11/16/07 1:05 PM Page ii

Pro JavaScript™ Design Patterns


Copyright © 2008 by Ross Harmes and Dustin Diaz
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval
system, without the prior written permission of the copyright owner and the publisher.
ISBN-13 (pbk): 978-1-59059-908-2
ISBN-10 (pbk): 1-59059-908-X
ISBN-13 (electronic): 978-1-4302-0495-4
ISBN-10 (electronic): 1-4302-0495-8
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence
of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark
owner, with no intention of infringement of the trademark.
Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems Inc. in the
United States and other countries. Apress Inc. is not affiliated with Sun Microsystems Inc., and this book
was written without endorsement from Sun Microsystems Inc.
Lead Editors: Chris Mills, Tom Welsh
Technical Reviewer: Simon Willison
Editorial Board: Steve Anglin, Ewan Buckingham, Tony Campbell, Gary Cornell, Jonathan Gennick,
Jason Gilmore, Kevin Goff, Jonathan Hassell, Matthew Moodie, Joseph Ottinger, Jeffrey Pepper,
Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh
Project Manager: Richard Dal Porto
Copy Editor: Jennifer Whipple
Associate Production Director: Kari Brooks-Copony
Production Editor: Kelly Winquist
Compositor and Artist: Kinetic Publishing Services, LLC
Proofreader: Dan Shaw
Indexer: Julie Grady
Cover Designer: Kurt Krames
Manufacturing Director: Tom Debolski
Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor,
New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected], or
visit http://www.springeronline.com.
For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600, Berkeley,
CA 94705. Phone 510-549-5930, fax 510-549-5939, e-mail [email protected], or visit http://www.apress.com.
The information in this book is distributed on an “as is” basis, without warranty. Although every precaution
has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to
any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly
by the information contained in this work.
The source code for this book is available to readers at http://www.apress.com.
908Xch00FM.qxd 11/16/07 1:05 PM Page iii

To Mom, and those who have listened, thanks


—Dustin Diaz

To Alec, Dymphi, and Terry


—Ross Harmes
908Xch00FM.qxd 11/16/07 1:05 PM Page iv
908Xch00FM.qxd 11/16/07 1:05 PM Page v

Contents at a Glance

About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv


About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi

PART 1 ■■■ Object-Oriented JavaScript


■CHAPTER 1 Expressive JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
■CHAPTER 2 Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
■CHAPTER 3 Encapsulation and Information Hiding . . . . . . . . . . . . . . . . . . . . . . . . . . 25
■CHAPTER 4 Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
■CHAPTER 5 The Singleton Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
■CHAPTER 6 Chaining . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

PART 2 ■■■ Design Patterns


■CHAPTER 7 The Factory Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
■CHAPTER 8 The Bridge Pattern. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
■CHAPTER 9 The Composite Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
■CHAPTER 10 The Facade Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
■CHAPTER 11 The Adapter Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
■CHAPTER 12 The Decorator Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
■CHAPTER 13 The Flyweight Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
■CHAPTER 14 The Proxy Pattern. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
■CHAPTER 15 The Observer Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
■CHAPTER 16 The Command Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
■CHAPTER 17 The Chain of Responsibility Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . 245

■INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263

v
908Xch00FM.qxd 11/16/07 1:05 PM Page vi
908Xch00FM.qxd 11/16/07 1:05 PM Page vii

Contents

About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv


About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi

PART 1 ■■■ Object-Oriented JavaScript


■CHAPTER 1 Expressive JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
The Flexibility of JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
A Loosely Typed Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Functions As First-Class Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
The Mutability of Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Design Patterns in JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

■CHAPTER 2 Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
What Is an Interface? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Benefits of Using Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Drawbacks of Using Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
How Other Object-Oriented Languages Handle Interfaces . . . . . . . . . . . . . 12
Emulating an Interface in JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Describing Interfaces with Comments . . . . . . . . . . . . . . . . . . . . . . . . . 14
Emulating Interfaces with Attribute Checking . . . . . . . . . . . . . . . . . . . 16
Emulating Interfaces with Duck Typing . . . . . . . . . . . . . . . . . . . . . . . . 17
The Interface Implementation for This Book . . . . . . . . . . . . . . . . . . . . . . . . . 18
The Interface Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
When to Use the Interface Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
How to Use the Interface Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Example: Using the Interface Class . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Patterns That Rely on the Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
vii
908Xch00FM.qxd 11/16/07 1:05 PM Page viii

viii ■CONTENTS

■CHAPTER 3 Encapsulation and Information Hiding . . . . . . . . . . . . . . . . . . . . 25


The Information Hiding Principle. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Encapsulation vs. Information Hiding . . . . . . . . . . . . . . . . . . . . . . . . . . 26
The Role of the Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Basic Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Fully Exposed Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Private Methods Using a Naming Convention . . . . . . . . . . . . . . . . . . . 30
Scope, Nested Functions, and Closures . . . . . . . . . . . . . . . . . . . . . . . . 32
Private Members Through Closures . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
More Advanced Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Static Methods and Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Singletons and Object Factories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Benefits of Using Encapsulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Drawbacks to Using Encapsulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

■CHAPTER 4 Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Why Do You Need Inheritance? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Classical Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
The Prototype Chain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
The extend Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Prototypal Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Asymmetrical Reading and Writing of Inherited Members . . . . . . . . 46
The clone Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Comparing Classical and Prototypal Inheritance . . . . . . . . . . . . . . . . . . . . . 49
Inheritance and Encapsulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Mixin Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Example: Edit-in-Place . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Using Classical Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Using Prototypal Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Using Mixin Classes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
When Should Inheritance Be Used? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

■CHAPTER 5 The Singleton Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65


The Basic Structure of the Singleton . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Namespacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
908Xch00FM.qxd 11/16/07 1:05 PM Page ix

■CONTENTS ix

A Singleton As a Wrapper for Page-Specific Code . . . . . . . . . . . . . . . . . . . . 68


A Singleton with Private Members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Using the Underscore Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Using Closures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Comparing the Two Techniques. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Lazy Instantiation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Branching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Example: Creating XHR Objects with Branching . . . . . . . . . . . . . . . . . . . . . 79
When Should the Singleton Pattern Be Used? . . . . . . . . . . . . . . . . . . . . . . . 81
Benefits of the Singleton Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Drawbacks of the Singleton Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82

■CHAPTER 6 Chaining . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
The Structure of a Chain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Building a Chainable JavaScript Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Using Callbacks to Retrieve Data from Chained Methods . . . . . . . . . . . . . 89
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

PART 2 ■■■ Design Patterns


■CHAPTER 7 The Factory Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
The Simple Factory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
The Factory Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
When Should the Factory Pattern Be Used? . . . . . . . . . . . . . . . . . . . . . . . . . 99
Dynamic Implementations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Combining Setup Costs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Abstracting Many Small Objects into One Large Object . . . . . . . . . . 99
Example: XHR Factory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Specialized Connection Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Choosing Connection Objects at Run-Time . . . . . . . . . . . . . . . . . . . . 103
Example: RSS Reader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Benefits of the Factory Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Drawbacks of the Factory Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
908Xch00FM.qxd 11/16/07 1:05 PM Page x

x ■CONTENTS

■CHAPTER 8 The Bridge Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109


Example: Event Listeners . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Other Examples of Bridges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
Bridging Multiple Classes Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Example: Building an XHR Connection Queue . . . . . . . . . . . . . . . . . . . . . . 111
Including the Core Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Including an Observer System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Developing the Queue Skeleton . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Implementing the Queue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
Where Have Bridges Been Used? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
When Should the Bridge Pattern Be Used? . . . . . . . . . . . . . . . . . . . . . . . . . 122
Benefits of the Bridge Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Drawbacks of the Bridge Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

■CHAPTER 9 The Composite Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125

The Structure of the Composite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126


Using the Composite Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Example: Form Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Putting It All Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Adding Operations to FormItem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Adding Classes to the Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Adding More Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Example: Image Gallery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Benefits of the Composite Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Drawbacks of the Composite Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

■CHAPTER 10 The Facade Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141


Some Facade Functions You Probably Already Know About. . . . . . . . . . . 141
JavaScript Libraries As Facades . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Facades As Convenient Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Example: Setting Styles on HTML Elements . . . . . . . . . . . . . . . . . . . . . . . . 144
Example: Creating an Event Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
General Steps for Implementing the Facade Pattern . . . . . . . . . . . . . . . . . 147
When Should the Facade Pattern Be Used? . . . . . . . . . . . . . . . . . . . . . . . . 148
Benefits of the Facade Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Drawbacks of the Facade Pattern. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
908Xch00FM.qxd 11/16/07 1:05 PM Page xi

■CONTENTS xi

■CHAPTER 11 The Adapter Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149


Characteristics of an Adapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Adapting Existing Implementations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
Example: Adapting One Library to Another . . . . . . . . . . . . . . . . . . . . . . . . . 150
Example: Adapting an Email API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Wrapping the Webmail API in an Adapter . . . . . . . . . . . . . . . . . . . . . 157
Migrating from fooMail to dedMail . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
When Should the Adapter Pattern Be Used? . . . . . . . . . . . . . . . . . . . . . . . . 158
Benefits of the Adapter Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Drawbacks of the Adapter Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158

■CHAPTER 12 The Decorator Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159


The Structure of the Decorator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
The Role of the Interface in the Decorator Pattern . . . . . . . . . . . . . . 163
The Decorator Pattern vs. the Composite Pattern . . . . . . . . . . . . . . 163
In What Ways Can a Decorator Modify Its Component? . . . . . . . . . . . . . . 164
Adding Behavior After a Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Adding Behavior Before a Method . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
Replacing a Method. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
Adding New Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
The Role of the Factory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
Function Decorators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
When Should the Decorator Pattern Be Used? . . . . . . . . . . . . . . . . . . . . . . 173
Example: Method Profiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Benefits of the Decorator Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Drawbacks of the Decorator Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177

■CHAPTER 13 The Flyweight Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179


The Structure of the Flyweight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
Example: Car Registrations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
Intrinsic and Extrinsic State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
Instantiation Using a Factory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Extrinsic State Encapsulated in a Manager . . . . . . . . . . . . . . . . . . . . 182
Managing Extrinsic State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Example: Web Calendar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Converting the Day Objects to Flyweights . . . . . . . . . . . . . . . . . . . . . 185
Where Do You Store the Extrinsic Data? . . . . . . . . . . . . . . . . . . . . . . 186
908Xch00FM.qxd 11/16/07 1:05 PM Page xii

xii ■CONTENTS

Example: Tooltip Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186


The Unoptimized Tooltip Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Tooltip As a Flyweight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Storing Instances for Later Reuse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
When Should the Flyweight Pattern Be Used? . . . . . . . . . . . . . . . . . . . . . . 192
General Steps for Implementing the Flyweight Pattern . . . . . . . . . . . . . . 193
Benefits of the Flyweight Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
Drawbacks of the Flyweight Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194

■CHAPTER 14 The Proxy Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197


The Structure of the Proxy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
How Does the Proxy Control Access to Its Real Subject? . . . . . . . 197
Virtual Proxy, Remote Proxy, and Protection Proxy . . . . . . . . . . . . . . 200
The Proxy Pattern vs. the Decorator Pattern . . . . . . . . . . . . . . . . . . . 201
When Should the Proxy Be Used? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Example: Page Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
General Pattern for Wrapping a Web Service . . . . . . . . . . . . . . . . . . . . . . . 205
Example: Directory Lookup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
General Pattern for Creating a Virtual Proxy . . . . . . . . . . . . . . . . . . . . . . . . 210
Benefits of the Proxy Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Drawbacks of the Proxy Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214

■CHAPTER 15 The Observer Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215


Example: Newspaper Delivery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Push vs. Pull . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Pattern in Practice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Building an Observer API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
Delivery Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Subscribe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Unsubscribe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Observers in Real Life. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Example: Animation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
Event Listeners Are Also Observers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
When Should the Observer Pattern Be Used? . . . . . . . . . . . . . . . . . . . . . . 223
Benefits of the Observer Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
Drawbacks of the Observer Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
908Xch00FM.qxd 11/16/07 1:05 PM Page xiii

■CONTENTS xiii

■CHAPTER 16 The Command Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225


The Structure of the Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Creating Commands with Closures . . . . . . . . . . . . . . . . . . . . . . . . . . 227
The Client, the Invoker, and the Receiver. . . . . . . . . . . . . . . . . . . . . . 227
Using Interfaces with the Command Pattern. . . . . . . . . . . . . . . . . . . 228
Types of Command Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
Example: Menu Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
The Menu Composites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
The Command Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Putting It All Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
Adding More Menu Items Later On . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Example: Undo and Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Implementing Undo with Nonreversible Actions By Logging
Commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Logging Commands for Crash Recovery . . . . . . . . . . . . . . . . . . . . . . 242
When to Use the Command Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
Benefits of the Command Pattern. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
Drawbacks of the Command Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244

■CHAPTER 17 The Chain of Responsibility Pattern . . . . . . . . . . . . . . . . . . . . . . 245


The Structure of the Chain of Responsibility. . . . . . . . . . . . . . . . . . . . . . . . 245
Passing on Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
Implementing a Chain of Responsibility in an Existing Hierarchy . . . . . . 254
Event Delegation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
When Should the Chain of Responsibility Pattern Be Used? . . . . . . . . . . 255
Example: Image Gallery Revisited. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
Using the Chain of Responsibility to Make Composites
More Efficient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Adding Tags to Photos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
Benefits of the Chain of Responsibility Pattern . . . . . . . . . . . . . . . . . . . . . 261
Drawbacks of the Chain of Responsibility Pattern . . . . . . . . . . . . . . . . . . . 262
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262

■INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263

f7670b088a34e6aa65a5685727db1ff4
908Xch00FM.qxd 11/16/07 1:05 PM Page xiv
908Xch00FM.qxd 11/16/07 1:05 PM Page xv

About the Authors

■ROSS HARMES is a front-end engineer for Yahoo! in Sunnyvale, California.


Educated as an electrical and computer engineer, Ross quickly put down
the soldering iron and oscilloscope and focused on the software aspect of
his degree. After discovering that debugging memory leaks is not much fun,
he dove into the muddy and turbulent waters of web programming. He has
been happily swimming there ever since.
This is Ross’s first book, but he has been publishing his stray thoughts
online for years. These days his technical ramblings can be found at
http://techfoolery.com.

■DUSTIN DIAZ is a user interface engineer for Google in Mountain View,


California. He enjoys writing JavaScript, CSS, and HTML, as well as making
interactive and usable interfaces to inspire passionate users. Dustin has
written articles for Vitamin and Digital Web Magazine, and posts regularly
about web development at his site, http://dustindiaz.com.

xv
908Xch00FM.qxd 11/16/07 1:05 PM Page xvi
908Xch00FM.qxd 11/16/07 1:05 PM Page xvii

About the Technical Reviewer

■SIMON WILLISON is a consultant on client- and server-side web development and a cocreator
of the Django web framework. Simon’s interests include OpenID, unobtrusive JavaScript,
and rapid application development. Before going freelance, Simon worked on Yahoo!’s
Technology Development team, and prior to that at the Lawrence Journal-World, an award-
winning local newspaper in Kansas. Simon maintains a popular web development weblog
at http://simonwillison.net/.

xvii
908Xch00FM.qxd 11/16/07 1:05 PM Page xviii
Discovering Diverse Content Through
Random Scribd Documents
1—Jack Harkaway’s School Days
2—Jack Harkaway’s Friends
3—Jack Harkaway After School Days
4—Jack Harkaway Afloat and Ashore
5—Jack Harkaway Among the Pirates
6—Jack Harkaway at Oxford
7—Jack Harkaway’s Struggles
8—Jack Harkaway’s Triumphs
9—Jack Harkaway Among the Brigands
10—Jack Harkaway’s Return
11—Jack Harkaway Around the World
12—Jack Harkaway’s Perils
13—Jack Harkaway in China
14—Jack Harkaway and the Red Dragon
15—Jack Harkaway’s Pluck
16—Jack Harkaway in Australia
17—Jack Harkaway and the Bushrangers
18—Jack Harkaway’s Duel
19—Jack Harkaway and the Turks
20—Jack Harkaway in New York
21—Jack Harkaway Out West
22—Jack Harkaway Among the Indians
23—Jack Harkaway’s Cadet Days
24—Jack Harkaway in the Black Hills
25—Jack Harkaway in the Toils
26—Jack Harkaway’s Secret of Wealth
27—Jack Harkaway, Missing
28—Jack Harkaway and the Sacred Serpent
29—The Fool of the Family
30—Mischievous Matt
31—Mischievous Matt’s Pranks
32—Bob Fairplay Adrift
33—Bob Fairplay at Sea
34—The Boys of St. Aldates
35—Billy Barlow
36—Larry O’Keefe
37—Sam Sawbones
38—Too Fast to Last
39—Home Base
40—Spider and Stump
41—Out for Fun
42—Rob Rollalong, Sailor
43—Rob Rollalong in the Wilds

44—Phil, the Showman By Stanley Norris


45—Phil’s Rivals By Stanley Norris
46—Phil’s Pluck By Stanley Norris
47—Phil’s Triumph By Stanley Norris
48—From Circus to Fortune By Stanley Norris
49—A Gentleman Born By Stanley Norris
50—For His Friend’s Honor By Stanley Norris
51—True to His Trust By Stanley Norris
52—Facing the Music By Stanley Norris
By William Murray
53—Jungles and Traitors
Graydon
54—The Rockspur Eleven By Burt L. Standish
By Robert Louis
55—Treasure Island
Stevenson
By William Murray
56—In Fort and Prison
Graydon
57—The Rockspur Rivals By Burt L. Standish
58—George Arnold’s Pluck By John De Morgan
59—The Golden Harpoon By Weldon J. Cobb
60—The Rockspur Nine By Burt L. Standish
61—Always on Duty By John De Morgan
62—On the Wing By Weldon J. Cobb
63—Twenty Thousand Leagues Under
By Jules Verne
the Sea
By William Murray
64—A Legacy of Peril
Graydon
65—Lost in the Ice By John De Morgan
66—The Young Railroader By Stanley Norris
67—The Tour of the Zero Club By Capt. Ralph Bonehill
68—The Young Railroader’s Flyer By Stanley Norris
69—The Silent City By Fred Thorpe
74—The Young Railroader’s Long Run By Stanley Norris
75—The Treasure of Star Island By Weldon J. Cobb
76—The Young Railroader’s Comrade By Stanley Norris
77—In Unknown Worlds By John De Morgan
78—The Young Railroader’s Promotion By Stanley Norris
79—A Trip to Mars By Weldon J. Cobb
80—The Young Railroader’s Chance By Stanley Norris
81—Rob Ranger’s Mine By Lieut. Lounsberry
82—Zip, the Acrobat By Victor St. Clair
83—Rob Ranger’s Cowboy Days By Lieut. Lounsberry
84—On His Merit By Victor St. Clair
85—Out For Sport By Wallace Kincaid
86—Where Duty Called By Victor St. Clair
87—Engineer Ralph By Frank H. MacDougal
88—Fortune’s Winding Trail By Roy Franklin
89—The Boy Conjurer By Victor St. Clair
90—The Go-Ahead Boys’ Legacy By Gale Richards
91—With Odds Against Him By Weldon J. Cobb
92—Sunset Ranch By Stanley Norris
93—Chums of the Prairie By Stanley Norris
94—The Young Range Riders By Stanley Norris
95—Jack Lightfoot, the Athlete By Maxwell Stevens
96—Jack Lightfoot’s Crack Nine By Maxwell Stevens
97—Jack Lightfoot Trapped By Maxwell Stevens
98—Jack Lightfoot’s Rival By Maxwell Stevens
99—Jack Lightfoot in Camp By Maxwell Stevens
100—Jack Lightfoot’s Canoe Trip By Maxwell Stevens
101—Jack Lightfoot’s Iron Arm By Maxwell Stevens
102—Jack Lightfoot’s Hoodoo By Maxwell Stevens
103—Jack Lightfoot’s Decision By Maxwell Stevens
104—Jack Lightfoot’s Gun Club By Maxwell Stevens
105—Jack Lightfoot’s Blind By Maxwell Stevens

In order that there may be no confusion, we desire to say that the


books listed below will be issued during the respective months in
New York City and vicinity. They may not reach the readers at a
distance promptly, on account of delays in transportation.

To be published in January, 1929.

106—Jack Lightfoot’s Capture By Maxwell Stevens


107—Jack Lightfoot’s Head Work By Maxwell Stevens

To be published in February, 1929.

108—Jack Lightfoot’s Wisdom By Maxwell Stevens


109—The Pride of Annapolis By Com. Luther G. Brownell
To be published in March, 1929.

110—The Haunted Hunter By Edward S. Ellis


111—An Annapolis Adventure By Com. Luther G. Brownell

To be published in April, 1929.

112—The Two Scouts By Edward S. Ellis


113—An Annapolis Hero By Com. Luther G. Brownell

To be published in May, 1929.

114—Among the Redskins By Edward S. Ellis


115—Making Good in the Navy By Com. Luther G. Brownell

To be published in June, 1929.

116—Tracked Through the Wilds By Edward S. Ellis


117—A Dash for Glory By Com. Luther G. Brownell
Nick Carter Still Lives!
For many years the stories of the adventures of Nicholas
Carter, the great American detective, have been favorites with
busy men in all walks of life. The reason is not hard to find.
They afford splendid relaxation and complete entertainment.

Some of the Nick Carter stories are among the greatest


detective stories ever written and will remain so, as long as the
English language is read.

Look over the list of these titles in the NEW MAGNET


LIBRARY and buy yourself a real treat.
NICK CARTER STORIES

New Magnet Library


Not a Dull Book in This List

ALL BY NICHOLAS CARTER


Nick Carter stands for an interesting detective story. The fact that
the books in this line are so uniformly good is entirely due to the
work of a specialist. The man who wrote these stories produced no
other type of fiction. His mind was concentrated upon the creation of
new plots and situations in which his hero emerged triumphantly
from all sorts of troubles and landed the criminal just where he
should be—behind the bars.

The author of these stories knew more about writing detective


stories than any other single person.

Following is a list of the best Nick Carter stories. They have been
selected with extreme care, and we unhesitatingly recommend each
of them as being fully as interesting as any detective story between
cloth covers which sells at ten times the price.

If you do not know Nick Carter, buy a copy of any of the New
Magnet Library books, and get acquainted. He will surprise and
delight you.

ALL TITLES ALWAYS IN PRINT


901—A Weird Treasure
902—The Middle Link
903—To the Ends of the Earth
904—When Honors Pall
905—The Yellow Brand
906—A New Serpent in Eden
907—When Brave Men Tremble
908—A Test of Courage
909—Where Peril Beckons
910—The Gargoni Girdle
911—Rascals & Co.
912—Too Late to Talk
913—Satan’s Apt Pupil
914—The Girl Prisoner
915—The Danger of Folly
916—One Shipwreck Too Many
917—Scourged by Fear
918—The Red Plague
919—Scoundrels Rampant
920—From Clew to Clew
921—When Rogues Conspire
922—Twelve in a Grave
923—The Great Opium Case
924—A Conspiracy of Rumors
925—A Klondike Claim
926—The Evil Formula
927—The Man of Many Faces
928—The Great Enigma
929—The Burden of Proof
930—The Stolen Brain
931—A Titled Counterfeiter
932—The Magic Necklace
933—’Round the World for a Quarter
934—Over the Edge of the World
935—In the Grip of Fate
936—The Case of Many Clews
937—The Sealed Door
938—Nick Carter and the Green Goods Men
939—The Man Without a Will
940—Tracked Across the Atlantic
941—A Clew from the Unknown
942—The Crime of a Countess
943—A Mixed-up Mess
944—The Great Money-order Swindle
945—The Adder’s Brood
946—A Wall Street Haul
947—For a Pawned Crown
948—Sealed Orders
949—The Hate that Kills
950—The American Marquis
951—The Needy Nine
952—Fighting Against Millions
953—Outlaws of the Blue
954—The Old Detective’s Pupil
955—Found in the Jungle
956—The Mysterious Mail Robbery
957—Broken Bars
958—A Fair Criminal
959—Won by Magic
960—The Piano Box Mystery
961—The Man They Held Back
962—A Millionaire Partner
963—A Pressing Peril
964—An Australian Klondike
965—The Sultan’s Pearls
966—The Double Shuffle Club
967—Paying the Price
968—A Woman’s Hand
969—A Network of Crime
970—At Thompson’s Ranch
971—The Crossed Needles
972—The Diamond Mine Case
973—Blood Will Tell
974—An Accidental Password
975—The Crook’s Double
976—Two Plus Two
977—The Yellow Label
978—The Clever Celestial
979—The Amphitheater Plot
980—Gideon Drexel’s Millions
981—Death in Life
982—A Stolen Identity
983—Evidence by Telephone
984—The Twelve Tin Boxes
985—Clew Against Clew
986—Lady Velvet
987—Playing a Bold Game
988—A Dead Man’s Grip
989—Snarled Identities
990—A Deposit Vault Puzzle
991—The Crescent Brotherhood
992—The Stolen Pay Train
993—The Sea Fox
994—Wanted by Two Clients
995—The Van Alstine Case
996—Check No. 777
997—Partners in Peril
998—Nick Carter’s Clever Protégé
999—The Sign of the Crossed Knives
1000—The Man Who Vanished
1001—A Battle for the Right
1002—A Game of Craft
1003—Nick Carter’s Retainer
1004—Caught in the Toils
1005—A Broken Bond
1006—The Crime of the French Café
1007—The Man Who Stole Millions
1008—The Twelve Wise Men
1009—Hidden Foes
1010—A Gamblers’ Syndicate
1011—A Chance Discovery
1012—Among the Counterfeiters
1013—A Threefold Disappearance
1014—At Odds with Scotland Yard
1015—A Princess of Crime
1016—Found on the Beach
1017—A Spinner of Death
1018—The Detective’s Pretty Neighbor
1019—A Bogus Clew
1020—The Puzzle of Five Pistols
1021—The Secret of the Marble Mantel
1022—A Bite of an Apple
1023—A Triple Crime
1024—The Stolen Race Horse
1025—Wildfire
1026—A Herald Personal
1027—The Finger of Suspicion
1028—The Crimson Clew
1029—Nick Carter Down East
1030—The Chain of Clews
1031—A Victim of Circumstances
1032—Brought to Bay
1033—The Dynamite Trap
1034—A Scrap of Black Lace
1035—The Woman of Evil
1036—A Legacy of Hate
1037—A Trusted Rogue
1038—Man Against Man
1039—The Demons of the Night
1040—The Brotherhood of Death
1041—At the Knife’s Point
1042—A Cry for Help
1043—A Stroke of Policy
1044—Hounded to Death
1045—A Bargain in Crime
1046—The Fatal Prescription
1047—The Man of Iron
1048—An Amazing Scoundrel
1049—The Chain of Evidence
1050—Paid with Death
1051—A Fight for a Throne
1052—The Woman of Steel
1053—The Seal of Death
1054—The Human Fiend
1055—A Desperate Chance
1056—A Chase in the Dark
1057—The Snare and the Game
1058—The Murray Hill Mystery
1059—Nick Carter’s Close Call
1060—The Missing Cotton King
1061—A Game of Plots
1062—The Prince of Liars
1063—The Man at the Window
1064—The Red League
1065—The Price of a Secret
1066—The Worst Case on Record
1067—From Peril to Peril
1068—The Seal of Silence
1069—Nick Carter’s Chinese Puzzle
1070—A Blackmailer’s Bluff
1071—Heard in the Dark
1072—A Checkmated Scoundrel
1073—The Cashier’s Secret
1074—Behind a Mask
1075—The Cloak of Guilt
1076—Two Villains in One
1077—The Hot Air Clew
1078—Run to Earth
1079—The Certified Check
1080—Weaving the Web
1081—Beyond Pursuit
1082—The Claws of the Tiger
1083—Driven from Cover
1084—A Deal in Diamonds
1085—The Wizard of the Cue
1086—A Race for Ten Thousand
1087—The Criminal Link
1088—The Red Signal
1089—The Secret Panel
1090—A Bonded Villain
1091—A Move in the Dark
1092—Against Desperate Odds
1093—The Telltale Photographs
1094—The Ruby Pin
1095—The Queen of Diamonds
1096—A Broken Trail
1097—An Ingenious Stratagem
1098—A Sharper’s Downfall
1099—A Race Track Gamble
1100—Without a Clew
1101—The Council of Death
1102—The Hole in the Vault
1103—In Death’s Grip
1104—A Great Conspiracy
1105—The Guilty Governor
1106—A Ring of Rascals
1107—A Masterpiece of Crime
1108—A Blow for Vengeance
1109—Tangled Threads
1110—The Crime of the Camera
1111—The Sign of the Dagger
1112—Nick Carter’s Promise
1113—Marked for Death
1114—The Limited Holdup
1115—When the Trap Was Sprung
1116—Through the Cellar Wall
1117—Under the Tiger’s Claws
1118—The Girl in the Case
1119—Behind a Throne
1120—The Lure of Gold
1121—Hand to Hand
1122—From a Prison Cell
1123—Dr. Quartz, Magician
1124—Into Nick Carter’s Web
1125—The Mystic Diagram
1126—The Hand that Won
1127—Playing a Lone Hand
1128—The Master Villain
1129—The False Claimant
1130—The Living Mask
1131—The Crime and the Motive
1132—A Mysterious Foe
1133—A Missing Man
1134—A Game Well Played
1135—A Cigarette Clew
1136—The Diamond Trail
1137—The Silent Guardian
1138—The Dead Stranger
1140—The Doctor’s Stratagem
1141—Following a Chance Clew
1142—The Bank Draft Puzzle
1143—The Price of Treachery
1144—The Silent Partner
1145—Ahead of the Game
1146—A Trap of Tangled Wire
1147—In the Gloom of Night
1148—The Unaccountable Crook
1149—A Bundle of Clews
1150—The Great Diamond Syndicate
1151—The Death Circle
1152—The Toss of a Penny
1153—One Step Too Far
1154—The Terrible Thirteen
1155—A Detective’s Theory
1156—Nick Carter’s Auto Trail
1157—A Triple Identity
1158—A Mysterious Graft
1159—A Carnival of Crime
1160—The Bloodstone Terror
1161—Trapped in His Own Net
1162—The Last Move in the Game
1163—A Victim of Deceit
1164—With Links of Steel
1165—A Plaything of Fate
1166—The Key Ring Clew
1167—Playing for a Fortune
1168—At Mystery’s Threshold
1169—Trapped by a Woman
1170—The Four Fingered Glove
1171—Nabob and Knave
1172—The Broadway Cross
1173—The Man Without a Conscience
1174—A Master of Deviltry
1175—Nick Carter’s Double Catch
1176—Doctor Quartz’s Quick Move
1177—The Vial of Death
1178—Nick Carter’s Star Pupils
1179—Nick Carter’s Girl Detective
1180—A Baffled Oath
1181—A Royal Thief
1182—Down and Out
1183—A Syndicate of Rascals
1184—Played to a Finish
1185—A Tangled Case
1186—In Letters of Fire
1187—Crossed Wires
1188—A Plot Uncovered
1189—The Cab Driver’s Secret
1190—Nick Carter’s Death Warrant
1191—The Plot that Failed
1192—Nick Carter’s Masterpiece
1193—A Prince of Rogues
1194—In the Lap of Danger
1195—The Man from London
1196—Circumstantial Evidence
1197—The Pretty Stenographer Mystery
1198—A Villainous Scheme
1199—A Plot Within a Plot
1200—The Elevated Railroad Mystery
1201—The Blow of a Hammer
1202—The Twin Mystery
1203—The Bottle with the Black Label
1204—Under False Colors
1205—A Ring of Dust
1206—The Crown Diamond
1207—The Blood-red Badge
1208—The Barrel Mystery
1209—The Photographer’s Evidence
1210—Millions at Stake
1211—The Man and His Price
1212—A Double-Handed Game
1213—A Strike for Freedom
1214—A Disciple of Satan
1215—The Marked Hand
1216—A Fight with a Fiend
1217—When the Wicked Prosper
1218—A Plunge into Crime
1219—An Artful Schemer
1220—Reaping the Whirlwind
1221—Out of Crime’s Depths
1222—A Woman at Bay
1223—The Temple of Vice
1224—Death at the Feast
1225—A Double Plot
1226—In Search of Himself
1227—A Hunter of Men
1228—The Boulevard Mutes
1229—Captain Sparkle, Pirate
1230—Nick Carter’s Fall
1231—Out of Death’s Shadow
1232—A Voice from the Past
1233—Accident or Murder?
1234—The Man Who Was Cursed
1235—Baffled, But Not Beaten
1236—A Case Without a Clew
1237—The Demon’s Eye
1238—A Blindfold Mystery
1239—Nick Carter’s Swim to Victory
1240—A Man to Be Feared
1241—Saved by a Ruse
1242—Nick Carter’s Wildest Chase
1243—A Nation’s Peril
1244—The Rajah’s Ruby
1245—The Trail of a Human Tiger
1246—The Disappearing Princess
1247—The Lost Chittendens
1248—The Crystal Mystery
1249—The King’s Prisoner
1250—Talika, the Geisha Girl
1251—The Doom of the Reds

In order that there may be no confusion, we desire to say that the


books listed below will be issued during the respective months in
New York City and vicinity. They may not reach the readers at a
distance promptly, on account of delays in transportation.

To be published in January, 1929.


1252—The Lady of Shadows
1253—The Mysterious Castle
1254—The Senator’s Plot

To be published in February, 1929.

1255—A Submarine Trail


1256—A War of Brains

To be published in March, 1929.

1257—Pauline—A Mystery
1258—The Confidence King

To be published in April, 1929.

1259—A Chase for Millions


1260—Shown on the Screen

To be published in May, 1929.

1261—The Streaked Peril


1262—The Room of Mirrors

To be published in June, 1929.


1263—A Plot for an Empire
1264—A Call on the Phone
READ
When you want real recreation in your leisure hours, read!
Read the Street & Smith Novels!

They are the cheapest and most interesting reading matter


published in America to-day. No jazz—no sex—just big, clean,
interesting books. There are hundreds of different titles, among
which you will find a lot of exactly the sort of reading you
want.

So, when you get tired of rolling around in your Lady Lizzie
or listening to the blah-blah of your radio, hie yourself to the
nearest news dealer, grab off a copy of a good detective,
adventure or love story, and then READ!

Read the Street & Smith Novels. Catalogue sent upon request.

Street & Smith Corporation


79 Seventh Avenue New York City

Printed in the U. S. A.
Transcriber’s Note:

The Contents has been provided by the transcriber.

Punctuation has been standardised. Spelling has been retained


as published in the original publication except as follows:

Page 9
neither of us got a soo changed to
neither of us got a sou

Page 14
As the drew out the little square changed to
As she drew out the little square

Page 24
you can bet your last soo changed to
you can bet your last sou

Page 43
I’ll go you, Chip changed to
I’ll go with you, Chip

Page 54
they didn’t pay any atention changed to
they didn’t pay any attention
Page 65
Then and there the Farnum Hall lads began changed to
Then and there the Farnham Hall lads began

Page 71
the frail craft and disapeared beneath changed to
the frail craft and disappeared beneath

Page 78
with some diffiiculty, climbed changed to
with some difficulty, climbed

Page 78
hasn’t a soo in his jeens changed to
hasn’t a sou in his jeans

Page 80
had up their sleves for you changed to
had up their sleeves for you

Page 85
it was his awkardness that caused changed to
it was his awkwardness that caused

Page 101
I’v got a hunch that changed to
I’ve got a hunch that

Page 112
my private oponion that changed to
my private opinion that

Page 119
From the zinc boz the solution drops changed to
From the zinc box the solution drops
Pages 131 and 138
The first pages of Chapters XX and XXI, transposed in the
original publication, have been ordered correctly in this
ebook

Page 133
Supose we rummage around changed to
Suppose we rummage around

Page 140
Between you and me, Ping, I believe changed to
Between you and me, Pink, I believe

Page 146
who was the the other fellow changed to
who was the other fellow

Page 165
Mirable dictu! changed to
Mirabile dictu!

Page 187
Shaw was down with tonsilitis changed to
Shaw was down with tonsillitis

Page 192
sound a whole lot worst changed to
sound a whole lot worse

Page 209
finish coronat opus changed to
finis coronat opus

Page 218
“Tough luck, Joe,” commisserated Clancy changed to
“Tough luck, Joe,” commiserated Clancy
Page 238
makee tlouble for’ you changed to
makee tlouble fo’ you

Page 243
not been very succesful changed to
not been very successful

Page 260
by jim’ Klismas changed to
by jim’ Klismus

Page 271
a whale of a mystey changed to
a whale of a mystery

Page 296
we didn’t come to Opir to camp changed to
we didn’t come to Ophir to camp

Page 302
carried full to the ore platfom changed to
carried full to the ore platform
*** END OF THE PROJECT GUTENBERG EBOOK FRANK
MERRIWELL, JR., IN ARIZONA; OR, CLEARING A RIVAL'S RECORD
***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States
copyright in these works, so the Foundation (and you!) can copy
and distribute it in the United States without permission and
without paying copyright royalties. Special rules, set forth in the
General Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the


free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree
to abide by all the terms of this agreement, you must cease
using and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only


be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project Gutenberg™
works in compliance with the terms of this agreement for
keeping the Project Gutenberg™ name associated with the
work. You can easily comply with the terms of this agreement
by keeping this work in the same format with its attached full
Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.

1.E. Unless you have removed all references to Project


Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:

This eBook is for the use of anyone anywhere in the United


States and most other parts of the world at no cost and
with almost no restrictions whatsoever. You may copy it,
give it away or re-use it under the terms of the Project
Gutenberg License included with this eBook or online at
www.gutenberg.org. If you are not located in the United
States, you will have to check the laws of the country
where you are located before using this eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is


derived from texts not protected by U.S. copyright law (does not
contain a notice indicating that it is posted with permission of
the copyright holder), the work can be copied and distributed to
anyone in the United States without paying any fees or charges.
If you are redistributing or providing access to a work with the
phrase “Project Gutenberg” associated with or appearing on the
work, you must comply either with the requirements of
paragraphs 1.E.1 through 1.E.7 or obtain permission for the use
of the work and the Project Gutenberg™ trademark as set forth
in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is


posted with the permission of the copyright holder, your use and
distribution must comply with both paragraphs 1.E.1 through
1.E.7 and any additional terms imposed by the copyright holder.
Additional terms will be linked to the Project Gutenberg™
License for all works posted with the permission of the copyright
holder found at the beginning of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files
containing a part of this work or any other work associated with
Project Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute


this electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the
Project Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™
works unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or


providing access to or distributing Project Gutenberg™
electronic works provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project


Gutenberg™ electronic work or group of works on different
terms than are set forth in this agreement, you must obtain
permission in writing from the Project Gutenberg Literary
Archive Foundation, the manager of the Project Gutenberg™
trademark. Contact the Foundation as set forth in Section 3
below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
law in creating the Project Gutenberg™ collection. Despite these
efforts, Project Gutenberg™ electronic works, and the medium
on which they may be stored, may contain “Defects,” such as,
but not limited to, incomplete, inaccurate or corrupt data,
transcription errors, a copyright or other intellectual property
infringement, a defective or damaged disk or other medium, a
computer virus, or computer codes that damage or cannot be
read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except


for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU AGREE
THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE, STRICT
LIABILITY, BREACH OF WARRANTY OR BREACH OF CONTRACT
EXCEPT THOSE PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE
THAT THE FOUNDATION, THE TRADEMARK OWNER, AND ANY
DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE
TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL,
PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE
NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person
or entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you
do or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookfinal.com

You might also like