BOOKZONE
Refactoring JavaScript: Turning Bad Code Into Good Code
Paperback
by Evan Burchard
SKU:9789352135417
Bulk Discount Get Exta 5% upto 10%
Share

Talk about your brand
Share information about your brand with your customers. Describe a product, make announcements, or welcome customers to your store.
If your JavaScript is a mess, frameworks can only do so much to help. No matter what framework, "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. With this hands-on guide, you’ll learn how test and refactor your existing code to help reduce complexity, improve readability, and gain confidence in the codebase.
Author Evan Burchard shows you how to identify areas of bad code, and then takes you through several refactoring methods for improving them. Techniques range from renaming variables to applying principles of functional and object-oriented programming. If you’re motivated to write better JavaScript code either on the frontend or backend, this book is a must.
- Use refactoring to restructure existing code, without changing its behavior
- Learn the relationship between refactoring and quality
- Explore the many versions of JavaScript in use today
- Create automated tests to confirm that your code works, and find bugs that slip through
- Learn how to refactor simple JavaScript structures, functions, and objects
- Refactor your codebase by applying object-oriented and functional programming principles
- Examine methods for refactoring asynchronous JavaScript
Table of Content
Chapter 1What Is Refactoring?
How Can You Guarantee Behavior Doesn’tChange?
What Is the Point of Refactoring if BehaviorDoesn’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 FunctionalProgramming
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 (IncludingAnticlass Stances)
Async
Functional
Tools
Non-JS-Specific but Relevant Sources
Me
