Table of Contents for
Mastering Modular JavaScript
Close
Version ebook
/
Retour
Mastering Modular JavaScript
by Nicolas Bevacqua
Published by O'Reilly Media, Inc., 2018
nav
Cover
Mastering Modular JavaScript
Mastering Modular JavaScript
Preface
Module Thinking
Modularity Principles
Module Design
Shaping Internals
Modular Patterns and Practices
Development Methodology and Philosophy
Index
About the Author
Colophon
Preface
Who Should Read This Book
Why Modular JavaScript?
How Is This Book Organized?
Conventions Used in This Book
O’Reilly Safari
How to Contact Us
Acknowledgments
Module Thinking
1.1 Introduction to Module Thinking
1.2 A Brief History of Modularity
1.2.1 Script Tags and Closures
1.2.2 RequireJS, AngularJS, and Dependency Injection
1.2.3 Node.js and the Advent of CommonJS
1.2.4 ES6, import, Babel, and Webpack
1.3 The Perks of Modular Design
1.4 Modular Granularity
1.5 Modular JavaScript: A Necessity
Modularity Principles
2.1 Modular Design Essentials
2.1.1 Single Responsibility Principle
2.1.2 API First
2.1.3 Revealing Pattern
2.1.4 Finding the Right Abstractions
2.1.5 State Management
2.2 CRUST: Consistent, Resilient, Unambiguous, Simple, and Tiny
2.2.1 Consistency
2.2.2 Resiliency
2.2.3 Unambiguity
2.2.4 Simplicity
2.2.5 Tiny Surface Areas
Module Design
3.1 Growing a Module
3.1.1 Composability and Scalability
3.1.2 Design for Today
3.1.3 Abstractions Evolve in Small Steps
3.1.4 Move Deliberately and Experiment
3.2 CRUST Considerations
3.2.1 Do Repeat Yourself, Occasionally
3.2.2 Feature Isolation
3.2.3 Trade-Offs When Designing Internals
3.3 Pruning a Module
3.3.1 Error Handling, Mitigation, Detection, and Solving
3.3.2 Documentation as an Art
3.3.3 Removing Code
3.3.4 Applying Context
Shaping Internals
4.1 Internal Complexity
4.1.1 Containing Nested Complexity
4.1.2 Feature Entanglement and Tight Coupling
4.1.3 Frameworks: The Good, the Bad, and the Ugly
4.2 Refactoring Complex Code
4.2.1 Embracing Variables over Clever Code
4.2.2 Guard Clauses and Branch Flipping
4.2.3 An Interdependency Pyramid
4.2.4 Extracting Functions
4.2.5 Flattening Nested Callbacks
4.2.6 Factoring Similar Tasks
4.2.7 Slicing Large Functions
4.3 State as Entropy
4.3.1 Current State: It’s Complicated
4.3.2 Eliminating Incidental State
4.3.3 Containing State
4.3.4 Leveraging Immutability
4.4 Data Structures Are King
4.4.1 Isolating Data and Logic
4.4.2 Restricting and Clustering Logic
Modular Patterns and Practices
5.1 Leveraging Modern JavaScript
5.1.1 Template Literals
5.1.2 Destructuring, Rest, and Spread
5.1.3 Striving for Simple const Bindings
5.1.4 Navigating Callbacks, Promises, and Asynchronous Functions
5.2 Composition and Inheritance
5.2.1 Inheritance Through Classes
5.2.2 The Perks of Composition: Aspects and Extensions
5.2.3 Choosing Between Composition and Inheritance
5.3 Code Patterns
5.3.1 Revealing Module
5.3.2 Object Factories
5.3.3 Event Emission
5.3.4 Message Passing and the Simplicity of JSON
Development Methodology and Philosophy
6.1 Secure Configuration Management
6.2 Explicit Dependency Management
6.3 Interfaces as Black Boxes
6.4 Build, Release, Run
6.5 Statelessness
6.6 Parity in Development and Production
6.7 Abstraction Matters
Index