Advanced Search
Start Your Free Trial

Overview

Top Sellers in this Category

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 OOP 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.

Amazon.com® Reader Reviews (Ranked by Helpfulness)

Average Amazon.com® Rating: 4.5 out of 5 rating Based on 14 Ratings

the best book i've ever read about javascript OOP - 2008-09-01
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
the book is amazing and front-end engineer should not miss this one , it take you to the Guru level of knowledge with javascript OOP techniques and API creation world through Dustin diaz (Google) and Ross harmes (YahOO!) experience , beginning with OOP fundamentals in the first 6 chapters , then dive into the interesting javascript design patterns : Factory , Bridge , Composite , Facade , Adapter , Decorator , flyweight , Proxy , Observer and Command , i don't exaggerate when i tell you that it's the best book i've ever read about javascript in my life :) .

Great Design Pattern Book - 2009-05-28
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
When you read the book, "Pro JavaScript Design Patterns" from Ross Harmes and Dustin Diaz, it's clear that Ross and Dustin have a strong understanding of JavaScript, its strengths, and its limitations. JavaScript has a lot of stengths, in that it supports dynamic typing at runtime, public and private typing of members, flexible coding style , and existing support of class/object development. Its weaknesses, such as support for other constructs, like explicit namespaces or interface support, the writers attempt to make up for by showing potential workarounds to the issue.

The first three chapters setup some of the more complex topics: flexibility and mutability of objects, dynamic typing, structuring of classes and how to assign methods to an object's prototype. Another important subject is the differentiation between public and private members, and how these members are scoped and accessed in the class's instance.

Speaking of classes, there are a couple of different ways to setup class definitions and inheritance. The first option is prototypical inheritance, where the derived class inherits the members of the base class. Other options are mixin classes, using a helper method to copy over class definitions from one object to another. This book, with great detail, discusses the differences between the two options.
The book continues to discuss the following design patterns, and implements in full JavaScript. The concepts in the first four chapters, discussed above, are reused in the design pattern process. Each chapter highlighted below has an explanation, example (or several), guide on when to implement, pros, cons, and summary.

* Singleton Pattern - While not following the exact traditional pattern that you would see in other server-based environments, like the .NET framework, the Singleton pattern implemented in JavaScript provides a central accessible object to the application. The book also covers the subject of lazy instantiation and brancing of internal members (one example cited was to vary method implementation by browser).
* Chaining - More commonly seen in the JQuery library, chaining is the creation of a central object that gets returned from every method call. Within the prototype of every (or at least most) method is a call to return that same object. This way, the object can call one method after the other, after the other, in a more convenient fashion.
* Factory Pattern - The factory pattern provides a way to create the correct object using some sort of identifier (string, enum, object, etc.). The factory pattern instantiates an object that inherits from the same base class type, and thus the factory is responsible for its instantiation.
* Bridge Pattern - This pattern bridges multiple classes together that implement a similar functionality. It's a way to break out logical components into different objects, and follow more closely the Singular Responsibility pattern.
* Composite Pattern - This pattern requires that a particular set of objects all implement the same interface,regardless of whether a specific function is used within that object or not. The pattern is made up of leaf elements (elements at the bottom of the structure), and composite elements (which have one or more composite/leaf elements). The example used to illustrate this pattern is displaying of individual elements (textboxes and such), versus displaying composite elements.
* FaGÇíade Pattern - The faGÇíade pattern simplifies common tasks by grouping them into a parent function. For example, there are various nuances in JavaScript that vary by browser. The faGÇíade pattern facilitates working around these nuances by creating a central object with a method that checks browser type, and calls the correct method. From then on, the developer has to call this one method, instead of handling the various JavaScript nuances.
* Adapter Pattern - The adapter pattern provides a common interface across disparate interfaces that provide differing implementations. For instance, suppose you had to integrate various web service implementations. Each implementation would have a different implementation; the adapter pattern can accommodate this by providing one common interface, which this object then interacts with the web service.
* Decorator Pattern - The decorator pattern can be used to modify the behavior of its target. Decorators can be strung together to continually alter its behavior in some way, providing that each decorator alters the object appropriately. The chapter also explains what to watch out for when implementing this pattern, such as the order the patterns are created and processed.
* Flyweight Pattern - This pattern provides a caching to reuse commonly used elements, to make the underlying processes run faster. The system would first check the cache to see if the object exists before instantiating it.
* Proxy Pattern - A proxy provides access control to its underlying object's methods calls. It implements the same methods as its target, and can be a way to optimize usage of resources (especially expensive ones). This isn't necessarily related to just security in this regard. There are three types of proxies: virtual proxy, remote proxy, and protection proxy.
* Observer Pattern - The observer pattern uses subscribers and publishers. The publisher publishes to its subscriber that some event happened, and the subscriber can react to it in some way. One approach is through the use of a delegate that the publisher can call.
* Command Pattern - A command is some action that occurs within the application. A command provides a specific interface that varying command objects implement. The command can then be executed and perform its underlying action: this may be copy, paste, undo, or other operations.
* Chain of Responsibility Pattern - The chain of responsibility pattern is similar to some of the above patterns: it uses a chaining approach, which consists of firstly the sender, followed by a series of receivers that will process or ignore the request. It's a complex design pattern that the book describes very well.

Most of the chapters are explained very well; some of the examples didn't make the most sense to me as I didn't fully grasp some of the patterns. It's clear the authors know a lot more about design patterns than I do. However, don't let that detract you from the book because reading it again and trying it out yourself will help you to grasp the fundamentals. Alternatively, most of the examples are clear, concise, and to the topic at hand.

The book is a small book, consisting of many chapters (nicely broken out so I was able to do one a day). It has a lot of power to the punch for its size, which makes it a great book, and a great overview of design patterns in the JavaScript world, a world much different than most server-based languages.

Not too bad, but nothing really groundbreaking - 2009-11-15
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
Title pretty much says it all. I find myself skimming more than reading as there's a lot of common sense stuff in here with a few interesting nuggets from time to time.

One of the best javascript books - 2009-09-20
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
This book is really useful for Novice javascript programmer. It covers lot of basic details with good examples.

What every JS coder needs in their arsenal - 2009-07-20
Reviewer Rating: 1 star rating2 star rating3 star rating4 star rating5 star rating
This is the perfect book for any intermediate JS coder. The first part of the book discusses advanced topics like closures, object scope, prototypal inheritance, and first-order functions. The rest builds upon this foundation, showing the reader various design patterns.

The authors do a great job of covering each pattern. Each chapter discusses theory, when/where to use, the pros and cons, all with excellent sample code. Everything is explained in plain English. The book is rather concise though, so you may require a second reading to fully absorb and understand everything.

I thought I knew it all before reading this book but clearly I was wrong! Any JS programmer can write better code after reading this book, even if they don't implement any of the patterns.

You will NOT regret this purchase!!

Browse Similar Topics

Top Level Categories:
Programming

Sub-Categories:
Programming > JavaScript

Some information on this page was provided using data from Amazon.com®. View at Amazon >


About Safari Books Online • Terms of Service • Privacy Policy • Contact Us • Corporate Licenses • Help • Accessibility | See us on FacebookSee us on Linked InSee us on TwitterRSS

Copyright 2009 Safari Books Online. All rights reserved.