Diaz / Harmes | Pro JavaScript Design Patterns | E-Book | www2.sack.de
E-Book

E-Book, Englisch, 269 Seiten

Diaz / Harmes Pro JavaScript Design Patterns


1. ed
ISBN: 978-1-4302-0496-1
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark

E-Book, Englisch, 269 Seiten

ISBN: 978-1-4302-0496-1
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark



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.

Diaz / Harmes Pro JavaScript Design Patterns jetzt bestellen!

Autoren/Hrsg.


Weitere Infos & Material


1;Contents at a Glance;5
2;Contents;6
3;About the Authors;13
4;About the Technical Reviewer;14
5;Acknowledgments;15
6;Introduction;16
6.1;Who This Book Is For;16
6.2;How This Book Is Structured;17
6.3;Prerequisites;20
6.4;Downloading the Code;21
6.5;Contacting the Authors;21
7;Object-Oriented JavaScript;22
7.1;Expressive JavaScript;23
7.1.1;The Flexibility of JavaScript;23
7.1.2;A Loosely Typed Language;26
7.1.3;Functions As First- Class Objects;26
7.1.4;The Mutability of Objects;28
7.1.5;Inheritance;29
7.1.6;Design Patterns in JavaScript;29
7.1.7;Summary;30
7.2;Interfaces;31
7.2.1;What Is an Interface?;31
7.2.2;How Other Object- Oriented Languages Handle Interfaces;32
7.2.3;Emulating an Interface in JavaScript;34
7.2.4;The Interface Implementation for This Book;38
7.2.5;The Interface Class;39
7.2.6;Patterns That Rely on the Interface;43
7.2.7;Summary;43
7.3;Encapsulation and Information Hiding;44
7.3.1;The Information Hiding Principle;44
7.3.2;Basic Patterns;45
7.3.3;More Advanced Patterns;54
7.3.4;Benefits of Using Encapsulation;58
7.3.5;Drawbacks to Using Encapsulation;58
7.3.6;Summary;59
7.4;Inheritance;60
7.4.1;Why Do You Need Inheritance?;60
7.4.2;Classical Inheritance;61
7.4.3;Prototypal Inheritance;64
7.4.4;Comparing Classical and Prototypal Inheritance;68
7.4.5;Inheritance and Encapsulation;68
7.4.6;Mixin Classes;69
7.4.7;Example: Edit- in- Place;71
7.4.8;When Should Inheritance Be Used?;81
7.4.9;Summary;82
7.5;The Singleton Pattern;83
7.5.1;The Basic Structure of the Singleton;83
7.5.2;Namespacing;84
7.5.3;A Singleton As a Wrapper for Page- Specific Code;86
7.5.4;A Singleton with Private Members;88
7.5.5;Lazy Instantiation;93
7.5.6;Branching;96
7.5.7;Example: Creating XHR Objects with Branching;97
7.5.8;When Should the Singleton Pattern Be Used?;99
7.5.9;Benefits of the Singleton Pattern;99
7.5.10;Drawbacks of the Singleton Pattern;100
7.5.11;Summary;100
7.6;Chaining;101
7.6.1;The Structure of a Chain;102
7.6.2;Building a Chainable JavaScript Library;104
7.6.3;Using Callbacks to Retrieve Data from Chained Methods;107
7.6.4;Summary;108
8;Design Patterns;109
8.1;The Factory Pattern;110
8.1.1;The Simple Factory;110
8.1.2;The Factory Pattern;113
8.1.3;When Should the Factory Pattern Be Used?;116
8.1.4;Example: XHR Factory;116
8.1.5;Example: RSS Reader;121
8.1.6;Benefits of the Factory Pattern;124
8.1.7;Drawbacks of the Factory Pattern;125
8.1.8;Summary;125
8.2;The Bridge Pattern;126
8.2.1;Example: Event Listeners;126
8.2.2;Other Examples of Bridges;127
8.2.3;Bridging Multiple Classes Together;128
8.2.4;Example: Building an XHR Connection Queue;128
8.2.5;When Should the Bridge Pattern Be Used?;139
8.2.6;Benefits of the Bridge Pattern;140
8.2.7;Drawbacks of the Bridge Pattern;140
8.2.8;Summary;140
8.3;The Composite Pattern;141
8.3.1;The Structure of the Composite;142
8.3.2;Using the Composite Pattern;142
8.3.3;Example: Form Validation;143
8.3.4;Example: Image Gallery;152
8.3.5;Benefits of the Composite Pattern;155
8.3.6;Drawbacks of the Composite Pattern;155
8.3.7;Summary;156
8.4;The Facade Pattern;157
8.4.1;Some Facade Functions You Probably Already Know About;157
8.4.2;JavaScript Libraries As Facades;158
8.4.3;Facades As Convenient Methods;159
8.4.4;Example: Setting Styles on HTML Elements;160
8.4.5;Example: Creating an Event Utility;162
8.4.6;General Steps for Implementing the Facade Pattern;163
8.4.7;When Should the Facade Pattern Be Used?;164
8.4.8;Benefits of the Facade Pattern;164
8.4.9;Drawbacks of the Facade Pattern;164
8.4.10;Summary;164
8.5;The Adapter Pattern;165
8.5.1;Characteristics of an Adapter;165
8.5.2;Adapting Existing Implementations;166
8.5.3;Example: Adapting One Library to Another;166
8.5.4;Example: Adapting an Email API;168
8.5.5;When Should the Adapter Pattern Be Used?;174
8.5.6;Benefits of the Adapter Pattern;174
8.5.7;Drawbacks of the Adapter Pattern;174
8.5.8;Summary;174
8.6;The Decorator Pattern;175
8.6.1;The Structure of the Decorator;175
8.6.2;In What Ways Can a Decorator Modify Its Component?;180
8.6.3;The Role of the Factory;185
8.6.4;Function Decorators;188
8.6.5;When Should the Decorator Pattern Be Used?;189
8.6.6;Example: Method Profiler;189
8.6.7;Benefits of the Decorator Pattern;192
8.6.8;Drawbacks of the Decorator Pattern;192
8.6.9;Summary;193
8.7;The Flyweight Pattern;194
8.7.1;The Structure of the Flyweight;194
8.7.2;Example: Car Registrations;194
8.7.3;Managing Extrinsic State;198
8.7.4;Example: Web Calendar;198
8.7.5;Example: Tooltip Objects;201
8.7.6;Storing Instances for Later Reuse;205
8.7.7;When Should the Flyweight Pattern Be Used?;207
8.7.8;General Steps for Implementing the Flyweight Pattern;208
8.7.9;Benefits of the Flyweight Pattern;208
8.7.10;Drawbacks of the Flyweight Pattern;209
8.7.11;Summary;209
8.8;The Proxy Pattern;211
8.8.1;The Structure of the Proxy;211
8.8.2;When Should the Proxy Be Used?;215
8.8.3;Example: Page Statistics;215
8.8.4;General Pattern for Wrapping a Web Service;219
8.8.5;Example: Directory Lookup;220
8.8.6;General Pattern for Creating a Virtual Proxy;224
8.8.7;Benefits of the Proxy Pattern;227
8.8.8;Drawbacks of the Proxy Pattern;227
8.8.9;Summary;228
8.9;The Observer Pattern;229
8.9.1;Example: Newspaper Delivery;229
8.9.2;Building an Observer API;232
8.9.3;Observers in Real Life;234
8.9.4;Example: Animation;235
8.9.5;Event Listeners Are Also Observers;236
8.9.6;When Should the Observer Pattern Be Used?;237
8.9.7;Benefits of the Observer Pattern;237
8.9.8;Drawbacks of the Observer Pattern;237
8.9.9;Summary;237
8.10;The Command Pattern;238
8.10.1;The Structure of the Command;238
8.10.2;Types of Command Objects;241
8.10.3;Example: Menu Items;243
8.10.4;Example: Undo and Logging;248
8.10.5;When to Use the Command Pattern;255
8.10.6;Benefits of the Command Pattern;256
8.10.7;Drawbacks of the Command Pattern;256
8.10.8;Summary;257
8.11;The Chain of Responsibility Pattern;258
8.11.1;The Structure of the Chain of Responsibility;258
8.11.2;Passing on Requests;264
8.11.3;Implementing a Chain of Responsibility in an Existing Hierarchy;267
8.11.4;Event Delegation;268
8.11.5;When Should the Chain of Responsibility Pattern Be Used?;268
8.11.6;Example: Image Gallery Revisited;269
8.11.7;Benefits of the Chain of Responsibility Pattern;274
8.11.8;Drawbacks of the Chain of Responsibility Pattern;275
8.11.9;Summary;275
9;Index;276



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.