[Reconstruction: improving the design of existing code] Reading Notes -- Opening part: Restructuring Reading Notes

Source: Internet
Author: User

[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.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.