About the inspiration brought by reading the book "When and How to Refactor"

foreword

Recently, I read the book "The Timing and Method of Refactoring" written by Christian Clausen and translated by Guo Tao. After reading this book, you will find that "The Timing of Refactoring" "And Methods" is a classic software development book, which can help software developers improve code quality and work efficiency. As a programmer, I think this book is very helpful to me, and I have gained a lot of insights. Next article Just to share.

Specific reading gains

After reading the book "When and How to Refactor", I think its most important contribution is that it clearly expounds the concepts and principles of refactoring. As mentioned in the book, refactoring refers to the process of improving the internal structure of a software system without changing its external behavior. This definition is very precise and very practical. In actual software development, we often encounter problems such as code redundancy, excessive complexity, and poor design, which will seriously affect the readability, maintainability, and scalability of the code. Through refactoring, we can effectively solve these problems, making the code easier to understand, modify and extend. In addition, the book also introduces some important design principles, such as single responsibility principle, opening and closing principle, Liskov substitution principle, etc. These principles can help us design better software systems.

Moreover, the book "When and How to Refactor" introduces the timing and method of refactoring in great detail. The author presents situations such as: code that is difficult to understand, difficult to modify, adding new features requires extensive modification, etc., which indicate that the code needs to be refactored. In addition, the author also mentioned two modes of refactoring: preventive refactoring and patchy refactoring. Preventive refactoring is refactoring done before the code has problems, in order to avoid future problems. The repair refactoring is refactoring after the code has problems, the purpose is to solve the existing problems. Through these introductions, readers can understand when refactoring is needed, and learn how to refactor when and how to do it.

Also, the book details the basic techniques of refactoring. These techniques include: extract method, inline method, extract variable, inline variable, move method, add method, move field, wrap field, and replace algorithm, etc. These techniques are very practical and can help us quickly improve code quality. For example, extracting methods can help us encapsulate repeated code into one method, improving the readability and maintainability of the code; moving methods can help us move methods to more appropriate locations, making the code clearer and easier to understand.

And, the book describes how to use tests to support refactoring. Testing is an important means of supporting refactoring, because it can help us verify whether the refactored code still meets the original requirements. The author proposes some testing techniques, such as: unit testing, integration testing, regression testing, etc. At the same time, the author also introduced how to use the code coverage tool to check the test coverage. Through the introduction of this book, readers can learn how to use tests to support refactoring, and how to use code coverage tools to check test coverage.

Plus, the book shows how to do large-scale refactoring. Large-scale refactoring refers to the refactoring of an entire software system, which is a challenging task. The author proposes strategies such as: do small refactoring first, use patterns to guide refactoring, use automated tools, etc. These strategies can help us efficiently perform large-scale refactoring.

Finally, I think one of the strengths of this book is that it is very practical. The author provides a large number of examples and exercises, allowing readers to learn refactoring techniques through practical operations. In addition, this book also introduces some common anti-patterns (anti-patterns), these anti-patterns will lead to low-quality and inefficient code, readers can avoid making the same mistakes in the development process by understanding these anti-patterns.

Attachment: Details and table of contents of "The Timing and Method of Refactoring"

By the way, I would like to share the detailed information and catalog of the book "The Timing and Method of Refactoring". Developers who need it should act quickly.

Details of "When and How to Refactor":

京东网上商城https://union-click.jd.com/jdc?e=&p=JF8BAPoJK1olXwQGUFlUCksfCl8IHloRXAcAU24ZVxNJXF9RXh5UHw0cSgYYXBcIWDoXSQVJQwYHVVpcCUkQHDZNRwYlC1ZwU1oqT1V3C2hzbSd8D3NdLloPXkcbM2oIGlsUVQ4KUF1tC0oVAWgPG1kWVDYyVF9tWiXPtdnQvuoJiayNgdbKOEonA2gBE1MXXgcFUFlaDXsXC2s4Rh9JBVkBUm5tOEgnM18IK1glA2gDB1hfCRhDUQFVQQlAFAQEVDBYCUgUAW4LHGsXXAcAVm5tOD1sSi0PexttIHZ5MDk9azAWXCkOQSVVXGgAJjkmdi91eBd1RARjJgRCDght

The core content of "The Timing and Method of Refactoring":

Part I Learning by Refactoring Computer Games

Chapter 1 Refactoring

Chapter 2 Internals of Refactoring

Chapter 3 Splitting Long Functions

Chapter 4 Putting Type Codes to Work

Chapter 5 Melting Similar Code Together

Chapter 6 Protecting Data

Part II Applying what you have learned

Chapter 7 Working with the Compiler

Chapter 8 Stay away from annotations

Chapter 9 Like Deleting Code

Chapter 10: Never Be Afraid to Add Code

Chapter 11 Follow Structure in Code

Chapter 12 Avoiding Optimization and Generalization

0

conclusion

Overall, I personally think that "The Timing and Methods of Refactoring" is a very good software development book. It introduces the concepts, principles, timing, methods and techniques of refactoring in detail, so that readers can fully understand refactoring process and practice. In actual software development, we should choose the appropriate timing and method for refactoring according to the specific situation. Refactoring can not only help us improve code quality, but also help us improve design, making software systems more stable, reliable, easy to maintain and expand. In addition, the book also provides a large number of examples and exercises, allowing readers to learn refactoring techniques through practice. If you are a software developer, or are interested in software development, I highly recommend reading this book.

Guess you like

Origin blog.csdn.net/CC1991_/article/details/131926840