Nicht aus der Schweiz? Besuchen Sie lehmanns.de

Pro JavaScript Design Patterns (eBook)

eBook Download: PDF
2008 | 1st ed.
269 Seiten
Apress (Verlag)
978-1-4302-0496-1 (ISBN)

Lese- und Medienproben

Pro JavaScript Design Patterns - Dustin Diaz, Ross Harmes
Systemvoraussetzungen
79,99 inkl. MwSt
(CHF 78,15)
Der eBook-Verkauf erfolgt durch die Lehmanns Media GmbH (Berlin) zum Preis in Euro inkl. MwSt.
  • Download sofort lieferbar
  • Zahlungsarten anzeigen

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. The book then details how to implement and take advantage of several design patterns in JavaScript. 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.



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.
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, facades, 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

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.

Contents at a Glance 5
Contents 6
About the Authors 13
About the Technical Reviewer 14
Acknowledgments 15
Introduction 16
Who This Book Is For 16
How This Book Is Structured 17
Prerequisites 20
Downloading the Code 21
Contacting the Authors 21
Object-Oriented JavaScript 22
Expressive JavaScript 23
The Flexibility of JavaScript 23
A Loosely Typed Language 26
Functions As First- Class Objects 26
The Mutability of Objects 28
Inheritance 29
Design Patterns in JavaScript 29
Summary 30
Interfaces 31
What Is an Interface? 31
How Other Object- Oriented Languages Handle Interfaces 32
Emulating an Interface in JavaScript 34
The Interface Implementation for This Book 38
The Interface Class 39
Patterns That Rely on the Interface 43
Summary 43
Encapsulation and Information Hiding 44
The Information Hiding Principle 44
Basic Patterns 45
More Advanced Patterns 54
Benefits of Using Encapsulation 58
Drawbacks to Using Encapsulation 58
Summary 59
Inheritance 60
Why Do You Need Inheritance? 60
Classical Inheritance 61
Prototypal Inheritance 64
Comparing Classical and Prototypal Inheritance 68
Inheritance and Encapsulation 68
Mixin Classes 69
Example: Edit- in- Place 71
When Should Inheritance Be Used? 81
Summary 82
The Singleton Pattern 83
The Basic Structure of the Singleton 83
Namespacing 84
A Singleton As a Wrapper for Page- Specific Code 86
A Singleton with Private Members 88
Lazy Instantiation 93
Branching 96
Example: Creating XHR Objects with Branching 97
When Should the Singleton Pattern Be Used? 99
Benefits of the Singleton Pattern 99
Drawbacks of the Singleton Pattern 100
Summary 100
Chaining 101
The Structure of a Chain 102
Building a Chainable JavaScript Library 104
Using Callbacks to Retrieve Data from Chained Methods 107
Summary 108
Design Patterns 109
The Factory Pattern 110
The Simple Factory 110
The Factory Pattern 113
When Should the Factory Pattern Be Used? 116
Example: XHR Factory 116
Example: RSS Reader 121
Benefits of the Factory Pattern 124
Drawbacks of the Factory Pattern 125
Summary 125
The Bridge Pattern 126
Example: Event Listeners 126
Other Examples of Bridges 127
Bridging Multiple Classes Together 128
Example: Building an XHR Connection Queue 128
When Should the Bridge Pattern Be Used? 139
Benefits of the Bridge Pattern 140
Drawbacks of the Bridge Pattern 140
Summary 140
The Composite Pattern 141
The Structure of the Composite 142
Using the Composite Pattern 142
Example: Form Validation 143
Example: Image Gallery 152
Benefits of the Composite Pattern 155
Drawbacks of the Composite Pattern 155
Summary 156
The Facade Pattern 157
Some Facade Functions You Probably Already Know About 157
JavaScript Libraries As Facades 158
Facades As Convenient Methods 159
Example: Setting Styles on HTML Elements 160
Example: Creating an Event Utility 162
General Steps for Implementing the Facade Pattern 163
When Should the Facade Pattern Be Used? 164
Benefits of the Facade Pattern 164
Drawbacks of the Facade Pattern 164
Summary 164
The Adapter Pattern 165
Characteristics of an Adapter 165
Adapting Existing Implementations 166
Example: Adapting One Library to Another 166
Example: Adapting an Email API 168
When Should the Adapter Pattern Be Used? 174
Benefits of the Adapter Pattern 174
Drawbacks of the Adapter Pattern 174
Summary 174
The Decorator Pattern 175
The Structure of the Decorator 175
In What Ways Can a Decorator Modify Its Component? 180
The Role of the Factory 185
Function Decorators 188
When Should the Decorator Pattern Be Used? 189
Example: Method Profiler 189
Benefits of the Decorator Pattern 192
Drawbacks of the Decorator Pattern 192
Summary 193
The Flyweight Pattern 194
The Structure of the Flyweight 194
Example: Car Registrations 194
Managing Extrinsic State 198
Example: Web Calendar 198
Example: Tooltip Objects 201
Storing Instances for Later Reuse 205
When Should the Flyweight Pattern Be Used? 207
General Steps for Implementing the Flyweight Pattern 208
Benefits of the Flyweight Pattern 208
Drawbacks of the Flyweight Pattern 209
Summary 209
The Proxy Pattern 211
The Structure of the Proxy 211
When Should the Proxy Be Used? 215
Example: Page Statistics 215
General Pattern for Wrapping a Web Service 219
Example: Directory Lookup 220
General Pattern for Creating a Virtual Proxy 224
Benefits of the Proxy Pattern 227
Drawbacks of the Proxy Pattern 227
Summary 228
The Observer Pattern 229
Example: Newspaper Delivery 229
Building an Observer API 232
Observers in Real Life 234
Example: Animation 235
Event Listeners Are Also Observers 236
When Should the Observer Pattern Be Used? 237
Benefits of the Observer Pattern 237
Drawbacks of the Observer Pattern 237
Summary 237
The Command Pattern 238
The Structure of the Command 238
Types of Command Objects 241
Example: Menu Items 243
Example: Undo and Logging 248
When to Use the Command Pattern 255
Benefits of the Command Pattern 256
Drawbacks of the Command Pattern 256
Summary 257
The Chain of Responsibility Pattern 258
The Structure of the Chain of Responsibility 258
Passing on Requests 264
Implementing a Chain of Responsibility in an Existing Hierarchy 267
Event Delegation 268
When Should the Chain of Responsibility Pattern Be Used? 268
Example: Image Gallery Revisited 269
Benefits of the Chain of Responsibility Pattern 274
Drawbacks of the Chain of Responsibility Pattern 275
Summary 275
Index 276

Erscheint lt. Verlag 11.3.2008
Zusatzinfo 269 p.
Verlagsort Berkeley
Sprache englisch
Themenwelt Mathematik / Informatik Informatik Programmiersprachen / -werkzeuge
Mathematik / Informatik Informatik Web / Internet
Schlagworte Design • Design Pattern • Development • interfaces • JavaScript • language • object-oriented programming (OOP) • programming
ISBN-10 1-4302-0496-6 / 1430204966
ISBN-13 978-1-4302-0496-1 / 9781430204961
Haben Sie eine Frage zum Produkt?
PDFPDF (Wasserzeichen)
Größe: 1,3 MB

DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasser­zeichen und ist damit für Sie persona­lisiert. Bei einer missbräuch­lichen Weiter­gabe des eBooks an Dritte ist eine Rück­ver­folgung an die Quelle möglich.

Dateiformat: PDF (Portable Document Format)
Mit einem festen Seiten­layout eignet sich die PDF besonders für Fach­bücher mit Spalten, Tabellen und Abbild­ungen. Eine PDF kann auf fast allen Geräten ange­zeigt werden, ist aber für kleine Displays (Smart­phone, eReader) nur einge­schränkt geeignet.

Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.

Zusätzliches Feature: Online Lesen
Dieses eBook können Sie zusätzlich zum Download auch online im Webbrowser lesen.

Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.

Mehr entdecken
aus dem Bereich
Das umfassende Handbuch

von Johannes Ernesti; Peter Kaiser

eBook Download (2023)
Rheinwerk Computing (Verlag)
CHF 43,85
Das Handbuch für Webentwickler

von Philip Ackermann

eBook Download (2023)
Rheinwerk Computing (Verlag)
CHF 48,75