Refactoring at Scale: Regaining Control of Your Codebase

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Making significant changes to large, complex codebases is a daunting task--one that's nearly impossible to do successfully unless you have the right team, tools, and mindset. If your application is in need of a substantial overhaul and you're unsure how to go about implementing those changes in a sustainable way, then this book is for you. Software engineer Maude Lemaire walks you through the entire refactoring process from start to finish. You'll learn from her experience driving performance and refactoring efforts at Slack during a period of critical growth, including two case studies illustrating the impact these techniques can have in the real world. This book will help you achieve a newfound ability to productively introduce important changes in your codebase. • Understand how code degrades and why some degradation is inevitable • Quantify and qualify the state of your codebase before refactoring • Draft a well-scoped execution plan with strategic milestones • Win support from engineering leadership • Build and coordinate a team best suited for the project • Communicate effectively inside and outside your team • Adopt best practices for successfully executing the refactor

Author(s): Maude Lemaire
Edition: 1
Publisher: O'Reilly Media
Year: 2020

Language: English
Commentary: Vector PDF
Pages: 246
City: Sebastopol, CA
Tags: Software Engineering; Management; Risk; Scalability; Best Practices; Refactoring; Software Requirements; Communication; Strategy; Team Management; Version Control Systems; Technical Debt; Code Degradation; Cyclomatic Complexity

Cover
Copyright
Table of Contents
Preface
Who Should Read This Book
Why I Wrote This Book
Navigating This Book
Conventions Used in This Book
Using Code Examples
O’Reilly Online Learning
How to Contact Us
Acknowledgments
Part I. Introduction
Chapter 1. Refactoring
What Is Refactoring?
What Is Refactoring at Scale?
Why Should You Care About Refactoring?
Benefits of Refactoring
Developer Productivity
Identifying Bugs
Risks of Refactoring
Serious Regressions
Unearthing Dormant Bugs
Scope Creep
Unnecessary Complexity
When to Refactor
Small Scope
Code Complexity Actively Hinders Development
Shift in Product Requirements
Performance
Using a New Technology
When Not to Refactor
For Fun or Out of Boredom
Because You Happened to Be Passing By
To Making Code More Extendable
When You Don’t Have Time
Our First Refactoring Example
Simplifying Conditionals
Extracting Magic Numbers
Extracting Self-Contained Logic
Chapter 2. How Code Degrades
Why Understanding Code Degradation Matters
Requirement Shifts
Scalability
Accessibility
Device Compatibility
Environmental Changes
External Dependencies
Unused Code
Changes in Product Requirements
Tech Debt
Working Around Technology Choices
Persistent Lack of Organization
Moving Too Quickly
Applying Our Knowledge
Part II. Planning
Chapter 3. Measuring Our Starting State
Why Is Measuring the Impact of a Refactor Difficult?
Measuring Code Complexity
Halstead Metrics
Cyclomatic Complexity
NPath Complexity
Lines of Code
Test Coverage Metrics
Documentation
Formal Documentation
Informal Documentation
Version Control
Commit Messages
Commits in Aggregate
Reputation
Building a Complete Picture
Chapter 4. Drafting a Plan
Defining Your End State
On the Road
At Work
Mapping the Shortest Distance
On the Road
At Work
Identifying Strategic Intermediate Milestones
On the Road
At Work
Choosing a Rollout Strategy
Dark Mode/Light Mode
Smart DNA’s Rollout
Cleaning Up Artifacts
Referencing Metrics in Your Plan
Interpolating Goal Metrics to Intermediate Milestones
Distinct Milestone Metrics
Estimating
Sharing Your Plan with Other Teams
Transparency
Perspective
Refined Plan
Chapter 5. Getting Buy-In
Why Your Manager Is Not Onboard
Managers Aren’t Coding
Managers Are Evaluated Differently
Managers See the Risk
Managers Need to Coordinate
Strategies for Making a Compelling Argument
Using Conversational Devices
Building an Alignment Sandwich
Relying on Evidence
Playing Hardball
Buy-In Shapes the Refactor
Chapter 6. Building the Right Team
Identifying Different Kinds of Experts
Matchmaking
Experts of Many Trades
Revisiting Active Contributors
Biases in Our Expert List
Types of Refactoring Teams
Owners
Proposed Approach
Cleanup Crews
The Pitch
Metrics
Generosity
Opportunity
Bartering
Repeat
A Few Outcomes
Realistic Scenario
Worst-Case Scenario
Fostering Strong Teams
Part III. Execution
Chapter 7. Communication
Within Your Team
Stand-Ups
Weekly Syncs
Retrospectives
Outside Your Team
When Kicking Off the Project
During Project Execution
Always Iterate
Chapter 8. Strategies for Execution
Team Building
Pair Programming
Keeping Everyone Motivated
Keeping a Tally
Intermediate Metric Measurements
Unearthed Bugs
Clean-Up Items
Out-of-Scope Items
Programming Productively
Prototyping
Keep Things Small
Test, Test, Test
Asking the “Stupid” Question
Conclusion
Chapter 9. Making the Refactor Stick
Fostering Adoption
Education
Active Education
Passive Education
Reinforcement
Progressive Linting
Code Analysis Tools
Gates Versus Guardrails
Integrating Improvement into the Culture
Part IV. Case Studies
Chapter 10. Case Study: Redundant Database Schemas
Slack 101
Slack Architecture 101
Scalability Problems
Booting Up the Slack Client
File Visibility
Mentions
Consolidating the Tables
Gathering the Scattered Queries
Developing a Migration Strategy
Quantifying Our Progress
Attempting to Keep the Team Motivated
Communicating Our Progress
Tidying Up
Lessons Learned
Develop a Well-Defined, Well-Communicated Plan
Understand the Code’s History
Ensure Adequate Test Coverage
Keep Your Team Motivated
Focus on Strategic Milestones
Identify and Rely on Meaningful Metrics
Takeaways
Chapter 11. Case Study: Migrating to a New Database
Workspace-Sharded Data
Migrating channels_members to Vitess
Sharding Scheme
Developing a New Schema
Detangling JOINs
A Difficult Rollout
Backfill Mode
Dark Mode
Light Mode
Sunset Mode
Tidying Up
Lessons Learned
Set Realistic Estimates
Source the Teammates You Need
Plan Scope Carefully
Choose a Single Place for Project Communication
Design a Thoughtful Rollout Plan
Takeaways
Index
About the Author
Colophon