Facebook Pixel
Searching...
English
EnglishEnglish
EspañolSpanish
简体中文Chinese
FrançaisFrench
DeutschGerman
日本語Japanese
PortuguêsPortuguese
ItalianoItalian
한국어Korean
РусскийRussian
NederlandsDutch
العربيةArabic
PolskiPolish
हिन्दीHindi
Tiếng ViệtVietnamese
SvenskaSwedish
ΕλληνικάGreek
TürkçeTurkish
ไทยThai
ČeštinaCzech
RomânăRomanian
MagyarHungarian
УкраїнськаUkrainian
Bahasa IndonesiaIndonesian
DanskDanish
SuomiFinnish
БългарскиBulgarian
עבריתHebrew
NorskNorwegian
HrvatskiCroatian
CatalàCatalan
SlovenčinaSlovak
LietuviųLithuanian
SlovenščinaSlovenian
СрпскиSerbian
EestiEstonian
LatviešuLatvian
فارسیPersian
മലയാളംMalayalam
தமிழ்Tamil
اردوUrdu
Programming Javascript Applications

Programming Javascript Applications

Robust Web Architecture With Node, Html5, and Modern Js Libraries
by Eric Elliott 2012 300 pages
3.62
100+ ratings
Listen
Listen

Key Takeaways

1. JavaScript's Power: More Than Just a Toy

“Any application that can be written in JavaScript, will eventually be written in JavaScript.”

Ubiquitous and Powerful. Once relegated to simple browser effects, JavaScript has evolved into the most widely deployed programming language, powering everything from web applications to mobile apps and even hardware. Its low barrier to entry, combined with its expressive features, has made it a dominant force in modern software development.

  • JavaScript is used in operating systems, mobile devices, and embedded systems.
  • It's easy to learn, with a syntax familiar to C-family programmers.
  • It's a highly expressive language with advanced features.

The Rise of the Client. The shift of application logic to the client-side has been a major driver of JavaScript's growth. Modern JavaScript applications now handle tasks previously reserved for servers, such as templating and communication with vendor services. This has led to the creation of single-page applications that offer a more responsive and dynamic user experience.

  • Client-side logic handles templating and vendor service communication.
  • Modern JavaScript apps perform tasks previously done by desktop apps.
  • Servers now primarily serve static content, modules, and data.

Performance and Flexibility. JavaScript's performance has improved dramatically with just-in-time compiling, making it comparable to languages like C and C++. Its object-oriented features, including prototypal inheritance, offer a high degree of flexibility and dynamism.

  • Just-in-time compiling optimizes JavaScript for near-native performance.
  • Prototypal inheritance provides a flexible alternative to classical inheritance.
  • JavaScript supports encapsulation, polymorphism, and multiple inheritance.

2. Functions: The Versatile Building Blocks

“Functions are the building blocks of applications.”

Core of JavaScript. Functions are not just procedures; they are first-class objects that can be used anywhere a variable can be used. This allows for powerful techniques like higher-order functions, lambdas, and closures, which are essential for writing flexible and reusable code.

  • Functions can be used as variables, parameters, and return values.
  • Higher-order functions abstract away common coding patterns.
  • Lambdas are functions used as data, enabling flexible code patterns.

Best Practices. Writing good functions involves adhering to principles like "Don't Repeat Yourself" (DRY), "Do One Thing" (DOT), and "Keep It Simple Stupid" (KISS). Functions should be short, focused, and minimize side effects to enhance readability, reusability, and debuggability.

  • Functions should be short and focused on a single task.
  • Minimize side effects by returning copies instead of originals.
  • Pure functions have no side effects and always return the same value for the same inputs.

Function Definition and Scope. JavaScript offers various ways to define functions, including function declarations, function expressions, and method literals. Named function expressions provide the benefits of code organization and conditional function definition without cluttering stack traces with anonymous functions.

  • Function declarations are hoisted, while function expressions are not.
  • Named function expressions improve debugging by providing function names in stack traces.
  • Closures allow functions to access variables from their outer scope, enabling data privacy.

3. Objects: Flexible and Expressive

“JavaScript’s object system is so powerful and expressive that most of the complexity in common OO patterns melts away when you reproduce them in JavaScript.”

Prototypal Inheritance. JavaScript uses prototypal inheritance, where objects inherit properties and methods from prototype objects. This model is more flexible than classical inheritance, allowing for dynamic object extension and composition.

  • Objects inherit from prototypes, not classes.
  • Prototypes can be modified at any time, making JavaScript very dynamic.
  • Classical inheritance can be mimicked in JavaScript with less code.

Fluent-Style JavaScript. This style emphasizes using JavaScript's strengths, such as lambdas, object literals, dynamic object extension, prototypes, and factories, while discarding unnecessary constructs like constructor functions. It promotes code that is more concise, readable, and maintainable.

  • Object literals are the fastest way to create object instances.
  • Dynamic object extension allows for mixins and composition.
  • Factories are a more flexible alternative to constructor functions.

Object Creation and Patterns. JavaScript offers various ways to create objects, including object literals, constructor functions, and factory methods. Factories provide data privacy through closures and are a more flexible alternative to constructors. The flyweight pattern, using delegate prototypes, conserves resources by sharing methods and default properties.

  • Object literals are simple but lack data privacy.
  • Factories provide data privacy through closures.
  • The flyweight pattern uses delegate prototypes to share methods and data.

4. Modules: Encapsulation and Reusability

“Modules are reusable software components that form the building blocks of applications.”

Modularity Principles. Modules should be specialized, independent, decomposable, recomposable, and substitutable. They should encapsulate implementation details and expose a public API, allowing for changes without affecting other parts of the application.

  • Modules should have a specific function and a simple API.
  • They should communicate through mediators, not direct calls.
  • Modules should be easy to test, reuse, and substitute.

Module Patterns. JavaScript offers several ways to define modules, including the module pattern, CommonJS modules, and AMD. The module pattern uses an IIFE to encapsulate private data and expose a public interface. CommonJS modules, used in Node.js, use require() for dependencies and exports for the public API.

  • The module pattern uses an IIFE to encapsulate scope.
  • CommonJS modules use require() and exports.
  • AMD is used for asynchronous module loading in browsers.

Node-Style Modules and npm. Node.js uses CommonJS modules and npm for package management. npm allows for easy installation of modules and their dependencies, making it a powerful tool for building scalable applications.

  • npm is a package manager for Node.js.
  • It uses package.json to manage dependencies.
  • npm simplifies the process of installing and managing modules.

5. Separation of Concerns: The Key to Scalability

“Separation of concerns is the idea that each module or layer in an application should only be responsible for one thing and should not contain code that deals with other things.”

Core Principle. Separation of concerns involves dividing an application into distinct modules or layers, each responsible for a specific aspect of functionality. This approach reduces complexity, improves maintainability, and enhances code reusability.

  • Each module should have a single responsibility.
  • Modules should communicate through well-defined interfaces.
  • Separation of concerns improves code organization and maintainability.

Client-Side Concerns. Common client-side concerns include module management, events, presentation, internationalization, data management, routing, logging, analytics, authentication, and feature toggling. Libraries and frameworks often provide mechanisms to address these concerns.

  • Module management provides a standard architecture for modules.
  • Events enable communication between modules.
  • Presentation handles UI rendering and user interactions.

Module Management and Events. Module management systems provide namespacing, a sandbox of common functionality, access to environment variables, lifecycle hooks, and an event system for inter-module communication. Event emitters, aggregators, and queues are common patterns for managing asynchronous communication.

  • Event emitters notify objects of state changes.
  • Event aggregators decouple emitters and listeners.
  • Message queues provide reliable communication between modules.

6. Access Control: Securing Your Application

“Before you grant access to a resource, you need to know that the user is who she claims to be (authentication) and whether or not the user should have access to a given resource (authorization).”

Authentication and Authorization. Access control involves both authentication (verifying user identity) and authorization (granting access to resources based on user privileges). Passwords, multifactor authentication, and federated/delegated authentication are common methods for verifying user identity.

  • Authentication verifies user identity.
  • Authorization grants access to resources based on user privileges.
  • Passwords should be stored with one-way encryption hashes and salts.

Multifactor Authentication. Multifactor authentication combines multiple authentication factors, such as knowledge (passwords), possession (mobile phones), and inherence (biometrics), to enhance security. This approach makes it more difficult for attackers to gain unauthorized access.

  • Multifactor authentication uses multiple authentication factors.
  • Possession factors include OTPs generated by mobile apps.
  • Inherence factors include biometrics, but are not as secure.

OAuth 2.0 and Application Authorization. OAuth 2.0 is an open standard for application authorization, allowing clients to access resources on behalf of users. It provides a secure way for applications to request and obtain access tokens, enabling them to interact with third-party services.

  • OAuth 2.0 allows applications to access resources on behalf of users.
  • It uses access tokens to grant limited access to resources.
  • It provides a secure way for applications to interact with third-party services.

7. Logging: Essential for Debugging and Analysis

“Logging is a critical piece of application infrastructure, particularly in a modern JavaScript application.”

Purpose of Logging. Logging is essential for debugging, server operations, security, auditing, business analytics, and marketing. It provides a record of application events, errors, and user interactions, enabling developers and administrators to monitor and analyze system behavior.

  • Logging is used for debugging, operations, security, and analytics.
  • It provides a record of application events and errors.
  • It enables monitoring and analysis of system behavior.

What to Log. Logs should include requests, errors, conversion goals, authorizations, feature activations, and performance metrics. Sensitive information, such as passwords and credit card numbers, should be redacted.

  • Log requests, errors, and conversion goals.
  • Redact sensitive information from logs.
  • Include timestamps, request IDs, and user information.

Client-Side Logging. Client-side events can be logged using a tracking pixel or a dedicated logging endpoint. This allows for tracking user interactions and performance metrics on the client side.

  • Use a tracking pixel or a dedicated endpoint for client-side logging.
  • Log user interactions and performance metrics.
  • Use a logging library like Bunyan for structured logging.

8. RESTful APIs: Designing for the Web

“API design is developer UX.”

RESTful Principles. RESTful APIs use HTTP methods to manipulate resources, focusing on the transfer of state rather than remote procedure calls. They should be usable, self-describing, efficient, and responsive.

  • RESTful APIs use HTTP methods to manipulate resources.
  • They focus on the transfer of state, not remote procedure calls.
  • They should be usable, self-describing, efficient, and responsive.

Usability and Consistency. API design should prioritize usability by focusing on clarity and consistency. API endpoints should be focused on specific resources, and they should adhere to standard REST conventions.

  • API endpoints should be focused on specific resources.
  • They should adhere to standard REST conventions.
  • Consistency makes APIs easier to learn and use.

Hypermedia and HATEOAS. Hypermedia as the Engine of Application State (HATEOAS) is a key principle of REST, where the server provides the client with the information it needs to interact with the API. This approach decouples the client from the server, making the API more flexible and maintainable.

  • HATEOAS decouples the client from the server.
  • It makes APIs more browsable and self-documenting.
  • It allows for API changes without breaking clients.

Last updated:

Review Summary

3.62 out of 5
Average of 100+ ratings from Goodreads and Amazon.

Programming Javascript Applications receives mixed reviews, with an average rating of 3.62/5. Readers appreciate its coverage of JavaScript application architecture, API building, and internationalization. Some find it informative for intermediate developers, praising its design philosophy and guidelines. However, criticisms include outdated content, shallow coverage of certain topics, and unclear transitions between client-side and server-side code. The book is seen as a good overview of ES5 JavaScript, but may not be suitable for advanced developers or those seeking in-depth explanations.

Your rating:

About the Author

Eric Elliott is a JavaScript developer and author known for his work on JavaScript application architecture and best practices. He has written extensively on functional programming, object-oriented design, and modular development in JavaScript. Elliott's expertise spans both client-side and server-side JavaScript, including Node.js. He has contributed to various open-source projects and developed his own libraries, which he references in his book. Elliott's writing style is praised for its clarity and ability to explain complex concepts, though some readers note that his examples can be specific to his own tools. His work aims to bridge the gap between theoretical concepts and practical application in real-world JavaScript development.

Download PDF

To save this Programming Javascript Applications summary for later, download the free PDF. You can print it out, or read offline at your convenience.
Download PDF
File size: 0.25 MB     Pages: 13

Download EPUB

To read this Programming Javascript Applications summary on your e-reader device or app, download the free EPUB. The .epub digital book format is ideal for reading ebooks on phones, tablets, and e-readers.
Download EPUB
File size: 2.95 MB     Pages: 13
0:00
-0:00
1x
Dan
Andrew
Michelle
Lauren
Select Speed
1.0×
+
200 words per minute
Create a free account to unlock:
Requests: Request new book summaries
Bookmarks: Save your favorite books
History: Revisit books later
Ratings: Rate books & see your ratings
Try Full Access for 7 Days
Listen, bookmark, and more
Compare Features Free Pro
📖 Read Summaries
All summaries are free to read in 40 languages
🎧 Listen to Summaries
Listen to unlimited summaries in 40 languages
❤️ Unlimited Bookmarks
Free users are limited to 10
📜 Unlimited History
Free users are limited to 10
Risk-Free Timeline
Today: Get Instant Access
Listen to full summaries of 73,530 books. That's 12,000+ hours of audio!
Day 4: Trial Reminder
We'll send you a notification that your trial is ending soon.
Day 7: Your subscription begins
You'll be charged on Feb 28,
cancel anytime before.
Consume 2.8x More Books
2.8x more books Listening Reading
Our users love us
50,000+ readers
"...I can 10x the number of books I can read..."
"...exceptionally accurate, engaging, and beautifully presented..."
"...better than any amazon review when I'm making a book-buying decision..."
Save 62%
Yearly
$119.88 $44.99/year
$3.75/mo
Monthly
$9.99/mo
Try Free & Unlock
7 days free, then $44.99/year. Cancel anytime.
Settings
Appearance
Black Friday Sale 🎉
$20 off Lifetime Access
$79.99 $59.99
Upgrade Now →