You are previewing Programming JavaScript Applications.
O'Reilly logo
Programming JavaScript Applications

Book Description

Take advantage of JavaScript’s power to build robust web-scale or enterprise applications that are easy to extend and maintain. By applying the design patterns outlined in this practical book, experienced JavaScript developers will learn how to write flexible and resilient code that’s easier—yes, easier—to work with as your code base grows.

Table of Contents

  1. Preface
    1. Conventions Used in This Book
    2. Using Code Examples
    3. Safari® Books Online
    4. How to Contact Us
    5. Thanks
    6. Introduction
    7. Who this Book is For
    8. Who this Book is Not For
    9. Unit Testing
    10. About the Author
  2. 1. The JavaScript Revolution
    1. Advantages of JavaScript
      1. Performance
      2. Objects
      3. Syntax
      4. First Class Functions
      5. Events
      6. Reusability
      7. The Net Result
    2. Anatomy of a Typical Modern JavaScript App
      1. Infrastructure
      2. JSON: Data Storage and Communication
      3. NoSQL Datastores
      4. RESTful JSON Web Services
  3. 2. Functions
    1. Minimize Side Effects
    2. Function Definition
      1. Named Function Expressions
      2. Lambdas
      3. Immediately Invoked Function Expressions
      4. Method Context
        1. Function.prototype.bind()
    3. Function Scope
      1. Hoisting
      2. Closures
    4. Method Design
      1. Named Parameters
      2. Function Polymorphism
        1. Method Dispatch
      3. Generics and Collection Polymorphism
      4. Method Chaining and Fluent APIs
    5. Functional Programming
      1. Stateless Functions (aka Pure Functions)
      2. Partial Application and Currying
    6. Asynchronous Operations
      1. Callbacks
      2. Promises and Deferreds
    7. Conclusion
  4. 3. Objects
    1. Classical Inheritance is Obsolete
    2. Fluent Style JavaScript
    3. Prototypes
      1. Delegate Prototypes
      2. Prototype Cloning
      3. The Flyweight Pattern
    4. Object Creation
    5. Factories
    6. Prototypal Inheritance With Stamps
    7. Conclusion
  5. 4. Modules
    1. Principles of Modularity
    2. Interfaces
    3. The Module Pattern
    4. Asynchronous Module Definition
      1. Plugins
    5. Node Style Modules
    6. npm
    7. ES6 Modules
    8. Building Client-Side Code With CommonJS, npm, Grunt, and Browserify
      1. Defining the App
      2. Feature Implementation
      3. Bundling and Deployment
      4. Conclusion
  6. 5. Separation of Concerns
    1. Client Side Concerns
      1. Module Management
        1. Getting Started
        2. Registration, Loading and Rendering
      2. Events
        1. Event Emitters
        2. Event Aggregators
        3. Queues and Stacks
        4. Choosing the Right Event Model
        5. Events by Example
      3. Model View Controller / MV*
      4. Presentation and DOM Manipulation
        1. View Events
          1. Event Delegation
        2. Templates
        3. Web Components
    2. Server Side Concerns
      1. Getting Started With Node and Express
        1. Installing Node and Express
        2. Organizing Files in Node
        3. Node Libraries
        4. Configuration
        5. Express
        6. Create your app
        7. Routing
        8. Middleware
          1. Let it Crash
        9. Templates
        10. Next Steps
    3. Conclusion
  7. 6. Access Control
    1. Authentication
      1. Passwords
        1. Rainbow Tables
          1. Password Salts
        2. Brute Force
        3. Variable Time Equality
        4. Stolen Passwords
      2. Credential
      3. Multi Factor Authentication
        1. Knowledge Factor
        2. Possession Factor
        3. Inherence Factor
      4. Federated and Delegated Authentication
        1. Mozilla Persona
        2. WebID
        3. Delegated Authentication
    2. Authorization
      1. Authorizing Applications
      2. OAuth 2.0
    3. Recap
  8. 7. Logging
    1. Debugging
    2. Server Operations
    3. Security
    4. Auditing
    5. Business Analytics
      1. Viral Factor
    6. Logging Checklist
    7. Logging Requests
    8. Logging Errors
    9. Sample Log Output
    10. Logging Service Alerts
    11. Logging Goals
    12. Profiling and Instrumentation
    13. Logging Client Side Events
    14. Deciphering Data
    15. Conclusion
  9. 8. Building RESTful APIs
    1. Usable
      1. Focus
      2. Consistency
        1. Use Common Conventions
        2. Resourceful Routing
    2. Self Describing - Hypermedia
      1. Affordances
      2. HATEOAS
      3. HTML as an API Media Type
      4. Jade
      5. Jiron
    3. Responsive APIs
    4. Optimizing for Speed
    5. Conclusion
  10. 9. Feature Toggle
    1. Organizing Features
      1. Scale of a Feature
      2. Feature Groups
    2. Lifespan of a Feature
      1. Development
      2. Staging
      3. Production Testing
      4. Feature Rollout
      5. Default Activation
      6. Full Integration
    3. Implementation
    4. Conclusion
  11. 10. Internationalization
    1. Conclusion
  12. A. JavaScript Style Guide
    1. Example Tests
    2. QUnit Primer
    3. Code Quality
    4. Best Practices Quick Reference
      1. Indentation - Be Consistent
      2. Use Semicolons
      3. Bracket Placement - Right Side
      4. Avoid Name Collisions
      5. Always Use Var
      6. Use One var Statement per Function
      7. Avoid Constant Abuse
      8. Use Functional Iterators When Possible
      9. Be Careful With if Statements
      10. Avoid Side Effects
      11. Don’t Use Switch
      12. Don’t Use Eval
  13. About the Author
  14. Copyright