|
Chapter 1: Expressive JavaScript - We dive into the expressive nature of the JavaScript language. We look at how the language allows you to use different styles to accomplish similar tasks, and how you can take alternative approaches to object-oriented programming by using concepts from functional programming.Chapter 2: Interfaces - We look at how other object-oriented languages implement interfaces and try to emulate the best features of each in JavaScript. We explore the options available for interface checking and come up with a reusable class that can be used to check objects for needed methods. Chapter 3: Encapsulation and Information Hiding - We explore the different ways in which objects can be created in JavaScript, and the techniques available within each to create public, private, and protected methods. We also take a look at the situations where using complex encapsulated objects can benefit the JavaScript programmer. Chapter 4: Inheritance - We look at the techniques that can be used to create subclasses in JavaScript. We cover both classical and prototypal inheritance, and outline the situations where it is appropriate to use each. We also discuss mixin classes and how they can be used as an alternative to multiple inheritance. Chapter 5: The Singleton Pattern - We discuss the uses of the singleton pattern in JavaScript. We cover namespacing, code organization, and branching, which can be used to define methods dynamically based on the run-time environment. Chapter 6: Chaining - We explore JavaScript’s ability to chain methods together and how this can lead to cleaner, more elegant code. We adapt this technique to create a small JavaScript library and compare the methods within it to the equivalent implementations that don’t utilize chaining. Chapter 7: The Factory Pattern - We look at the factory pattern, which helps decouple the classes that instantiate each other and instead uses a method to decide which specific class to instantiate. We discuss the simple factory pattern, which uses a separate class to create instances, and the more complex factory pattern, which uses subclasses to decide what concrete class to instantiate as a member object. Chapter 8: The Bridge Pattern - We look at a way of connecting two objects together without tightly coupling them. Bridges link two objects together while allowing them both to vary independently. We show you how to use bridges to loosely tie functions to events. Chapter 9: The Composite Pattern - We explore a design pattern that is tailor-made for creating dynamic user interfaces on the Web: the composite pattern. We show you how to use this pattern to initiate complex or recursive behaviors on many objects with a single command, and how to use it to organize objects into complex hierarchies. Chapter 10: The Facade Pattern - We discuss a way to create a more fully featured interface for an object. The facade pattern can be used to convert an existing interface into one that you can use more easily. We explain how most JavaScript libraries are facades over the specific browser’s implementation of the language. Chapter 11: The Adapter Pattern - We examine a pattern that allows you to mold existing interfaces to meet your needs. Adapters, also called wrappers, replace an incompatible interface with one that works in an existing system. Chapter 12: The Decorator Pattern - We look at a way to add features to objects without creating new subclasses. The decorator pattern is used to transparently wrap objects within another object of the same interface. Chapter 13: The Flyweight Pattern - We examine another optimization pattern, the flyweight. We show how it can be used to dramatically reduce the number of objects needed to implement your applications, by converting many independent objects into a few shared objects. Download free ebooks on javascript: Pro JavaScript Design Patterns
|
Free programing ebooks
Chapter 1: Expressive JavaScript - We dive into the expressive nature of the JavaScript language. We look at how the language allows you to use different styles to accomplish similar tasks, and how you can take alternative approaches to object-oriented programming by using concepts from functional programming.