Refactoring C# Code
In this chapter, we will look at the problem code and how to refactor it. In the industry, problematic code is normally termed code smell. It is code that compiles, runs, and does what it is supposed to do. The reason it is problem code is that it becomes unreadable, complex in nature, and makes the code base hard to maintain and extend further down the line. Such code should be refactored as soon as it’s feasible to do so. It is technical debt, and in the long run, if you don’t deal with it, it will bring the project to its knees. When this happens, you are looking at an expensive redesign and must recode the application from scratch.
So, what is refactoring? Refactoring is the process of taking existing code that works and rewriting it such that the code becomes clean. As you have already discovered, clean code is easy to read, easy to maintain, and easy to extend.
In this chapter, we will cover the following topics:
- Identifying application...