Reliable JavaScript
Реклама. ООО «ЛитРес», ИНН: 7719571260.
Оглавление
Lawrence Spencer. Reliable JavaScript
CREDITS
ABOUT THE AUTHORS
ABOUT THE TECHNICAL EDITORS
ACKNOWLEDGMENTS
INTRODUCTION
THE RISE OF JAVASCRIPT AS A FIRST-CLASS LANGUAGE
THE EASE OF WRITING TRULY DISASTROUS CODE IN JAVASCRIPT
THE EASE OF UNINTENTIONALLY BREAKING JAVASCRIPT CODE
THIS BOOK'S INTENDED AUDIENCE
HOW THIS BOOK IS STRUCTURED
WHAT YOU NEED TO USE THIS BOOK
CONVENTIONS
SOURCE CODE
ERRATA
P2P.WROX.COM
PART I. Laying a Solid Foundation
CHAPTER 1. Practicing Skillful Software Engineering
WRITING CODE THAT STARTS CORRECT
WRITING CODE THAT STAYS CORRECT
SUMMARY
CHAPTER 2. Tooling Up
USING A TESTING FRAMEWORK
USING A DEPENDENCY-INJECTION FRAMEWORK
USING AN ASPECT TOOLKIT
USING A CODE-CHECKING TOOL
SUMMARY
CHAPTER 3. Constructing Reliable Objects
USING PRIMITIVES
USING OBJECT LITERALS
USING THE MODULE PATTERN
USING OBJECT PROTOTYPES AND PROTOTYPAL INHERITANCE
CREATING OBJECTS WITH NEW
USING CLASSICAL INHERITANCE
USING FUNCTIONAL INHERITANCE
MONKEY-PATCHING
SUMMARY
PART II. Testing Pattern-Based Code
CHAPTER 4. Reviewing the Benefits of Patterns
CASE STUDY
PRODUCING MORE ELEGANT CODE BY USING A BROADER VOCABULARY
PRODUCING RELIABLE CODE WITH WELL-ENGINEERED, WELL-TESTED BUILDING BLOCKS
SUMMARY
CHAPTER 5. Ensuring Correct Use of the Callback Pattern
UNDERSTANDING THE PATTERN THROUGH UNIT TESTS
AVOIDING PROBLEMS
SUMMARY
CHAPTER 6. Ensuring Correct Use of the Promise Pattern
UNDERSTANDING PROMISES THROUGH UNIT TESTS
CHAINING PROMISES
USING A PROMISE WRAPPER
UNDERSTANDING STATES AND FATES
DISTINGUISHING STANDARD PROMISES FROM JQUERY PROMISES
SUMMARY
CHAPTER 7. Ensuring Correct Use of Partial Function Application
UNIT-TESTING A PARTIAL FUNCTION APPLICATION
CREATING AN ASPECT FOR PARTIAL FUNCTION APPLICATION
DISTINGUISHING BETWEEN PARTIAL FUNCTION APPLICATION AND CURRYING
SUMMARY
CHAPTER 8. Ensuring Correct Use of the Memoization Pattern
UNDERSTANDING THE PATTERN THROUGH UNIT TESTS
ADDING MEMOIZATION WITH AOP
SUMMARY
CHAPTER 9. Ensuring Correct Implementation of the Singleton Pattern
UNDERSTANDING THE PATTERN THROUGH UNIT TESTS
SUMMARY
CHAPTER 10. Ensuring Correct Implementation of the Factory Pattern
WRITING UNIT TESTS FOR A FACTORY
IMPLEMENTING THE FACTORY PATTERN
CONSIDERING OTHER FACTORY TYPES
SUMMARY
CHAPTER 11. Ensuring Correct Implementation and Use of the Sandbox Pattern
UNDERSTANDING THE PATTERN THROUGH UNIT TESTS
SUMMARY
CHAPTER 12. Ensuring Correct Implementation of the Decorator Pattern
DEVELOPING A DECORATOR THE TEST-DRIVEN WAY
SUMMARY
CHAPTER 13. Ensuring Correct Implementation of the Strategy Pattern
UNDERSTANDING THE PATTERN THROUGH UNIT TESTS
SUMMARY
CHAPTER 14. Ensuring Correct Implementation of the Proxy Pattern
DEVELOPING A PROXY THE TEST-DRIVEN WAY
SUMMARY
CHAPTER 15. Ensuring Correct Implementation of Chainable Methods
UNDERSTANDING THE PATTERN THROUGH UNIT TESTS
CHAINING THEN
SUMMARY
PART III. Testing and Writing with Advanced JavaScript Features
CHAPTER 16. Conforming to Interfaces in an Interface-Free Language
UNDERSTANDING THE BENEFITS OF INTERFACES
UNDERSTANDING THE INTERFACE SEGREGATION PRINCIPLE
USING TEST-DRIVEN DEVELOPMENT TO CREATE A CONTRACT REGISTRY
SUMMARY:
CHAPTER 17. Ensuring Correct Argument Types
UNDERSTANDING THE OPPORTUNITIES AND RISKS POSED BY JAVASCRIPT’S TYPE-FREE PARAMETERS
EXTENDING THE CONTRACTREGISTRY TO CHECK ARGUMENTS
SUPPORTING CONTRACT LIBRARIES
PUTTING IT ALL TOGETHER
COMPARING THE ASPECT-ORIENTED SOLUTION TO A STATIC SOLUTION
SUMMARY
CHAPTER 18. Ensuring Correct Use of call, apply, and bind
EXPLORING HOW THIS IS BOUND
CREATING AND TESTING CODE THAT USES CALL, APPLY, AND BIND
SUMMARY
CHAPTER 19. Ensuring Correct Use of Method-Borrowing
ENSURING THE BORROWING OBJECT IS SUITABLE
ANTICIPATING SIDE EFFECTS ON THE BORROWER
ANTICIPATING SIDE EFFECTS ON THE DONOR OBJECT
SUMMARY
CHAPTER 20. Ensuring Correct Use of Mixins
CREATING AND USING MIXINS
SUMMARY
CHAPTER 21. Testing Advanced Program Architectures
ENSURING RELIABLE USE OF THE OBSERVER PATTERN
ENSURING RELIABLE USE OF THE MEDIATOR PATTERN
SUMMARY
PART IV. Special Subjects in Testing
CHAPTER 22. Testing DOM Access
UNIT-TESTING UI
OPTIMIZING YOUR CODE WITH A PROFILER
SUMMARY
CHAPTER 23. Ensuring Conformance to Standards
USING ESLINT
ENFORCING ARCHITECTURAL DIVISIONS
SUMMARY
PART V. Summary
CHAPTER 24. Summary of the Principles of Test-Driven Development
RECALLING WHY TEST-DRIVEN DEVELOPMENT IS WORTHWHILE
PRACTICING TEST-DRIVEN DEVELOPMENT
SUMMARY
CHAPTER 25. Summary of JavaScript Idioms in This Book
REVIEWING OBJECTS
REVIEWING VARIABLES
REVIEWING FUNCTIONS
REVIEWING BOOLEAN OPERATIONS
SUMMARY
INDEX
WILEY END USER LICENSE AGREEMENT
Отрывок из книги
LARRY SPENCER is Vice President of Application Development at ScerIS, a software and services company in Sudbury, Massachusetts. He and his team create browser-based applications in AngularJS, with a C#/Web API/SQL Server back end. Larry's 35-year career has included stints programming in COBOL, C, C++, C#, and even mainframe assembly language, but he says JavaScript is the most fun. A frequent speaker at Code Camps and other gatherings, Larry enjoys sharing his love of software with the development community. You can find his blog at http://FascinatedWithSoftware.com.
Larry's outside interests include philosophy, chess, and classical guitar. He lives in Marlborough, Massachusetts.
.....
With globals popping into existence unbidden, an almost total lack of architectural tradition, a questionable relationship to the truth, and more quirkiness than you'd find at a cosplay convention, it's a wonder that JavaScript has done as well as she has in the world.
Believe it or not, it gets worse before it gets better. Even if you get it right, it can go wrong oh so easily.
.....