[Reconstruction: improving the design of existing code] Reading Notes -- Opening part: Restructuring Reading Notes
[Reconstruction: improving the design of existing code] the General Directory of Reading Notes
1. Reconstruction principles
2. Bad taste of code [1]
3,Bad taste of code [2]
4,Bad taste of code [3]
5,Bad taste of code [4]
6. refactoring Methods: Extrct Method (extraction function), Inline Method (Inline function), Inline Temp (Inline temporary variable)
7,Reconstruction Method Replace Temp With Query (Replace temporary variables With queries)
Write and update ......
Background
Refactoring is to improve code in an orderly manner without changing external behaviors.
Refactoring not only improves the existing design, but also helps us understand the process that was hard to understand. For example, for a complex conditional expression, it may take a long time for us to understand the role of this expression. It may take a long time for us to finally understand it. After a long time, we forget it, now let's look at it from the beginning. If we use the Extract Method to abstract this expression and give it an easy-to-understand name, if the function name is good, next time when we see this code, without looking at the logic, we know what this function is. If we reconstruct all the hard-to-understand aspects of this function, and abstract each small logic into a small function and give it an easy-to-understand name, when we look at the code, it may be like watching the annotation. We don't have to look at the implementation of the Code as before to guess what the code is doing. A good code is better than a comment, after all, annotations may not be updated in a timely manner.
Refactoring to improve the design of existing code is a classic. I believe many people have heard of it or read it. This book essentially recommends an excellent programming habit and attitude to us. While understanding the ideas of this book, we should also cultivate a kind of work attitude that strives for perfection, and explore a path that is more suitable for our own restructuring.
Do not write the code, nor follow the old saying [if it can run, do not touch it]. Optimize the code structure appropriately, it can bring more convenience for future development.
Although this book is written in Java and is a very old version of Java, it does not affect C # developers at all. The idea is the same because it has nothing to do with programming languages.