Book Image

Refactoring with Microsoft Visual Studio 2010

By : Peter Ritchie
Book Image

Refactoring with Microsoft Visual Studio 2010

By: Peter Ritchie

Overview of this book

<p>Changes to design are an everyday task for many people involved in a software project. Refactoring recognizes this reality and systematizes the distinct process of modifying design and structure without affecting the external behavior of the system. As you consider the benefits of refactoring, you will need this complete guide to steer you through the process of refactoring your code for optimum results.<br /><br />This book will show you how to make your code base more maintainable by detailing various refactorings. Visual Studio includes some basic refactorings that can be used independently or in conjunction to make complex refactorings easier and more approachable. This book will discuss large-scale code management, which typically calls for refactoring. To do this, we will use enterprise editions of Visual Studio, which incorporate features like Application Performance Explorer and Visual Studio Analyzer. These features make it simple to handle code and prove helpful for refactoring quickly.<br /><br />This book introduces you to improving a software system's design through refactoring. It begins with simple refactoring and works its way through complex refactoring. You will learn how to change the design of your software system and how to prioritize refactorings—including how to use various Visual Studio features to focus and prioritize design changes. The book also covers how to ensure quality in the light of seemingly drastic changes to a software system. You will also be able to apply standard established principles and patterns as part of the refactoring effort with the help of this book. You will be able to support your evolving code base by refactoring architectural behavior. As an end result, you will have an adaptable system with improved code readability, maintainability, and navigability.</p>
Table of Contents (17 chapters)
Refactoring with Microsoft Visual Studio 2010
Credits
About the Author
Acknowledgement
About the Reviewers
Preface
6
Improving Class Quality
9
Improving Architectural Behavior

Summary


Software projects are generally about writing and managing multi-release software with no fixed end-of-life and that evolves noticeably over time. This chapter has outlined how systematic refactoring efforts help in the evolution and management of software to avoid it from becoming brittle and keeping it robust in the face of change. Refactoring helps software developers be more amenable to accepting new requirements.

Writing software, although a science, is not always done perfectly. Many priorities affect how software is written. Sometimes, software isn't designed or written to use the best technique. Software that doesn't use the best technique (but is otherwise functional) is considered to have acquired technical debt. An increased debt load can lead to bankruptcy. By focusing code improvements on refactoring to reduce debt, software developers can avoid reaching a debt load that requires a re-write.

Refactoring efforts can have a specific impetus, or they may simply be part of a general effort to improve the maintainability of the software under development. There are many aspects that can help focus the refactoring efforts whether the impetus is specific or not.

In some code-bases there may be no specific focus on design focusing almost solely on functionality. Code-bases like this have inconsistent design styles and are hard to read, understand, and modify. By refactoring to specific design principles, code can be modified to improve its consumability, robustness, and changeability.

Refactoring to patterns help in maintaining software that is easily understandable and consumable to peers in the software industry. Use of patterns reduces the concepts consumers of code are required to understand before they can understand the overall intent of the code.

Refactoring code to remove code smells can help focus and prioritize the refactoring effort. By prioritizing standard smells and creating proprietary smells, maintainability of code can be enhanced focusing on improvements with the highest returns.

There are many aspects to how software is written and designed that is orthogonal to its functionality but directly related to its usability. Prioritizing refactoring efforts based on usability metrics like performance will give end users the same functionality, only faster.

There are many formulas for analyzing source code to gather specific metrics about the static structure of the code. These metrics are generally geared towards detecting attributes that are side effects of problems. These problems are often related to complexity. There are many tools that automatically gather metrics about code. Complex code has proven to be a major aspect contributing to hard-to-maintain software projects. Complex code reduces the ability of software to change to implement new features and increases the risk that these changes cause other problems. By gathering and prioritizing these metrics, code improvement can focus on refactoring complex code.

Focusing on improving code that when improved will result in the highest return, is an attractive option. By prioritizing change to areas of the code that are highly used or highly dependent can realize more noticeable benefits to the refactoring effort.

Refactoring is about preventative maintenance. As with any maintenance, a systematic approach to it can make the process more tolerable and in many ways it can make it enjoyable. Put some thought into what and where you want to improve your source code and you can avoid drudgery and focus on the value-added parts of your software.