I'm pleased to share that I have completed my first technical book: "Refactoring with C#" with Packt Publishing. The book is in final preparation for publishing and goes live on Amazon on November 24th.
I've been a developer for over several decades, I've worked with .NET since beta 2, and I've had the privilege to teach new learners .NET the past 3 years. To me, this book was the perfect opportunity to continue to invest in those people as their careers progressed from junior to mid and beyond.
During my time in the workforce, I've worked in less-than-optimal codebases (and even created a few myself). As part of stabilizing and improving those organizations, I learned to safely refactor code in a reliable and repeatable way. Refactoring with C# is my opportunity to share these techniques and strategies with engineering leaders responsible for maintaining old codebases and budding new developers who find themselves working in these areas.
The book provided an opportunity to talk about the latest and greatest .NET and C# features as well as sharing specific actionable tips around libraries like Shouldly, Scientist .NET, Snapper, and more to give you the safety net you need to make major changes and improve the stability and maintainability of your code.
The book is broken up into 4 major parts:
- Refactoring with C# in Visual Studio covers the refactoring process and tools. We start with some simple refactorings and then move into chapters dedicated to refactoring individual lines, full methods, and entire classes using object-oriented programming techniques.
- Refactoring Safely covers unit tests in xUnit, NUnit, and MSTest. This part starts at the basics, moves into data-driven tests and test-driven development, and then moves to advanced testing libraries and techniques. This section also covers SOLID principles as well as using modern C# language features (including some new to C# 12) to build safer codebases.
- Advanced Refactoring with AI and Code Analysis starts out with a tour of using GitHub Copilot Chat to help analyze, refactor, document, and test some code in need of refactoring. The following three chapters talk about code analysis systems and tools, with a heavy focus on the built-in Roslyn Analyzers. The final two chapters of this section explore how to create and publish Roslyn Analyzers of your own to flag issues and even automatically fix them.
- Refactoring in the Enterprise talks about organizational challenges in refactoring, including getting buy-in and time to change code, dealing with larger scale refactorings, and enforcing code standards through EditorConfig files.
The book is 17 chapters long and I had a blast writing it.
I wasn't alone in writing this book. In addition to Packt's editorial team, I had four amazing technical reviewers in Matthew Groves, Calvin Allen, Sam Gomez, and Brad Knowles. These individuals helped expand and contract the scope of each chapter, found a few issues in samples, and helped support the overall approach of the book.
Finally, Steve "Ardalis" Smith joined on as a foreword writer, but also provided a comprehensive technical review of the book with his own suggestions.
These individuals are all part of my regional tech community and share the same commitments I do in mentoring new developers and equipping seasoned developers with the tools and techniques they need to succeed.
Refactoring with C# releases on November 24th (Black Friday in the States) on Amazon in paperback and digital formats. It can also be found on Packt's website as well. The book was written against C# 12 and .NET 8 using Visual Studio 2022.