Refactoring JavaScript
O'Reilly Media (Verlag)
978-1-4919-6492-7 (ISBN)
How often do you hear people say things like this? "Our JavaScript is a mess, but we’re thinking about using [framework of the month]."
Like it or not, JavaScript is not going away. No matter what framework or ”compiles-to-js” language or library you use, bugs and performance concerns will always be an issue if the underlying quality of your JavaScript is poor. Rewrites, including porting to the framework of the month, are terribly expensive and unpredictable. The bugs won’t magically go away, and can happily reproduce themselves in a new context. To complicate things further, features will get dropped, at least temporarily.
The other popular method of fixing your JS is playing “JavaScript Jenga,” where each developer slowly and carefully takes their best guess at how the out-of-control system can be altered to allow for new features, hoping that this doesn’t bring the whole stack of blocks down. This book provides clear guidance on how best to avoid these pathological approaches to writing JavaScript:
- Recognize you have a problem with your JavaScript quality.
- Forgive the code you have now, and the developers who made it.
- Learn repeatable, memorable, and time-saving refactoring techniques.
- Apply these techniques as you work, fixing things along the way.
- Internalize these techniques, and avoid writing as much problematic code to begin with.
Evan Burchard is a Web Development Consultant and the author of The Web Game Developer's CookbookI. Offline, he has designed an award-winning kinetic game involving stacking real ice cubes, and periodically picks up his project to walk across the U.S
Chapter 1What Is Refactoring?
How Can You Guarantee Behavior Doesn’t Change?
What Is the Point of Refactoring if Behavior Doesn’t Change?
What Is and Isn’t Refactoring
Wrapping Up
Chapter 2Which JavaScript Are You Using?
Versions and Specifications
Platforms and Implementations
Precompiled Languages
Frameworks
Libraries
What JavaScript Do You Need?
What JavaScript Are We Using?
Wrapping Up
Chapter 3Testing
The Many Whys of Testing
The Many Ways of Testing
Tools and Processes
Wrapping Up
Chapter 4Testing in Action
New Code from Scratch
New Code from Scratch with TDD
Untested Code and Characterization Tests
Debugging and Regression Tests
Wrapping Up
Chapter 5Basic Refactoring Goals
Function Bulk
Inputs
Outputs
Side Effects
Context Part 1: The Implicit Input
Context Part 2: Privacy
Wrapping Up
Chapter 6Refactoring Simple Structures
The Code
Our Strategy for Confidence
Renaming Things
Useless Code
Variables
Strings
Working with Arrays: Loops, forEach, map
Wrapping Up
Chapter 7Refactoring Functions and Objects
The Code (Improved)
Array and Object Alternatives
Testing What We Have
Extracting Functions
Streamlining the API with One Global Object
Wrapping Up
Chapter 8Refactoring Within a Hierarchy
About “CRUD Apps” and Frameworks
Let’s Build a Hierarchy
Let’s Wreck Our Hierarchy
Inheritance and Architecture
Has-A Relationships
Inheritance Antipatterns
Wrapping Up
Chapter 9Refactoring to OOP Patterns
Template Method
Strategy
State
null Object
Wrapper (Decorator and Adapter)
Facade
Wrapping Up
Chapter 10Asynchronous Refactoring
Why Async?
Fixing the Pyramid of Doom
Callbacks and Testing
Promises
Wrapping Up
Chapter 11Functional Refactoring
The Restrictions and Benefits of Functional Programming
The Basics
Advanced Basics
Burritos
Learning and Using Burritos
Moving from OOP to FP
Wrapping Up
Chapter 12Conclusion
Appendix Further Reading and Resources
Origins of Refactoring
Baseline JavaScript(s)
Keeping Up with JavaScript
JavaScript Reference
Object-Oriented Programs/Patterns (Including Anticlass Stances)
Async
Functional
Tools
Non-JS-Specific but Relevant Sources
Me
Erscheinungsdatum | 31.03.2017 |
---|---|
Verlagsort | Sebastopol |
Sprache | englisch |
Maße | 150 x 250 mm |
Gewicht | 666 g |
Einbandart | kartoniert |
Themenwelt | Informatik ► Web / Internet ► JavaScript |
Schlagworte | JavaScript • Softwareentwicklung • Webdesign • Webentwicklung |
ISBN-10 | 1-4919-6492-8 / 1491964928 |
ISBN-13 | 978-1-4919-6492-7 / 9781491964927 |
Zustand | Neuware |
Haben Sie eine Frage zum Produkt? |
aus dem Bereich