当前位置:网站首页>Application layer software development Godfather teaches you how to refactor, senior programmers must professional skills
Application layer software development Godfather teaches you how to refactor, senior programmers must professional skills
2020-11-06 22:16:44 【Java architects Alliance】
Preface
Let's start with a little story
Once upon a time , A consultant visited a client to investigate his development project . The core of the system is the inheritance system , The consultant looked at some of the code written by the developers . He found the whole system quite messy , The upper superclass makes some assumptions about the operation of the system , The next subclass implements these assumptions . But these assumptions don't apply to all subclasses , Lead to overwrite (override) Work It's very heavy . Just make a change in the superclass , You can reduce a lot of rewriting . In other places , Some of the intentions of the superclass are not well understood , So some of these behaviors are repeated within subclasses . There are other places , Several subclasses do the same thing , In fact, they can be moved to the top of the inheritance system .
The consultant then advised the project manager to look at the code , Put them in order , But managers are not keen on it , After all, the program seems to work , And the project faces a lot of schedule pressure . So the manager said , Take time to do this later .
The consultant also shared his ideas with the programmers working on the inheritance system , Tell them what might happen . Programmers are sharp , We can see the seriousness of the problem immediately . They know it's not all their fault , Sometimes it really takes an outside force to find problems . It took the programmer a day or two to sort out the inheritance system , And cut out half of the code , Function intact . They are very satisfied with this , and It's faster to add new classes to the inheritance system or use other classes in the system 、 It's easier .
The project manager is not happy . It's a tight schedule , There is a lot of work to do . The system has to be released in a few months , And these programmers spent two days in vain , The work done has nothing to do with most of the features to be delivered . The original code runs normally , Their new design seems a bit too much of a perfectionist . The project is to be delivered to the customer , Is code that can run efficiently , It's not the perfect thing to please the pedant . The consultant then suggested that this sort of arrangement should be carried out in other core parts of the system , This will put the whole project on hold for a week or two . All this work is just to make the code look more beautiful , It doesn't add any new features to the system .
How do you feel about the story ? You think the consultant's advice ( To further organize the program ) Is that right ? Will you follow that old engineering proverb :“ If it still works , Just don't touch it .”
So , The author created this book ---《 restructure 》, I'd like to share it with you
Adapt to people
The target audience of this book is Professional programmers , Those who write software for a living . Examples and discussions in the book , It involves a lot of code that needs to be read and understood in detail . These examples are all in the form of Java It's written in . The reason for choosing Java, Because it's a language that is more and more widely used , and Anything with C Language background People can easily understand it .Java Is an object-oriented language , The object-oriented mechanism is very helpful for refactoring .
Although the focus is on Code , but Refactoring for system design It also has a huge impact . It's also important for senior designers and architects to understand the principles of refactoring , And use refactoring technology in your own projects . It's better to have seniority 、 Experienced developers introduce refactoring techniques , Because such people are the best at understanding the principles behind refactoring , And adjust it according to the situation , Apply it to a specific area of work . If you don't use Java, This is especially important , Because you have to rewrite my example in other languages .
Now I want to tell you , How to make full use of it without reading the whole book .
If you want to know why you should refactor , Please read the first two chapters . They tell you what refactoring is and why it should be refactored .
The first 1 Chapter reconstruction , The first case
The first 2 Chapter reconstruction principle
If you want to know where to refactor , Please read before 5 Chapter . It will tell you some code features , These characteristics point to “ We need to refactor ”.
The first 3 Bad smell of chapter code
The first 4 Chapter 2 constructs the test system
The first 5 Chapter refactoring list
The first 6 Chapter reorganizing functions
The first 7 Chapter moves features between objects
The first 8 Chapter reorganizing the data
The first 9 In this chapter, we simplify the conditional expression
The first 10 Chapter simplifying function calls
The first 11 Chapter deals with general relations
The first 12 Chapter large reconstruction
You need this information ,
Official account :Java Architects Alliance , Update the technology every day
If you want to start refactoring , From 5 The chapter extends to 12 Chapter . It can't be said to be a comprehensive list , It's just a start , It includes all the refactoring techniques I've sorted out in my work so far . I hope this is a part that you should review again and again in the future . Just skim the list at first , Look at some of them , You don't have to understand all the details . Once there is a real need to implement a code , Read it in more detail , Get help from . The list section is for reference , You don't have to read it all at once .
In addition, you should also read the list of other authors “ Guest section ”, Especially in the first 15 Chapter .
The first 13 Chapter reconstruction , Reuse and reality
The first 14 Chapter refactoring tool
The first 15 Chapter summary
So-called restructure (refactoring) It's a process like this : Without changing the external behavior of the code , Make changes to the code , To improve the internal structure of the program . Refactoring is a methodical method of program arrangement which has been formed through a lot of efforts , It can minimize the possibility of introducing errors in the finishing process . In essence , Refactoring is to improve the design of the code after it is written .
All right. , You need this information , Official account :Java Architects Alliance , Update the technology every day
版权声明
本文为[Java architects Alliance]所创,转载请带上原文链接,感谢
边栏推荐
- C++ 数字、string和char*的转换
- C++学习——centos7上部署C++开发环境
- C++学习——一步步学会写Makefile
- C++学习——临时对象的产生与优化
- C++学习——对象的引用的用法
- C++编程经验(6):使用C++风格的类型转换
- Won the CKA + CKS certificate with the highest gold content in kubernetes in 31 days!
- C + + number, string and char * conversion
- C + + Learning -- capacity() and resize() in C + +
- C + + Learning -- about code performance optimization
猜你喜欢
-
C + + programming experience (6): using C + + style type conversion
-
Latest party and government work report ppt - Park ppt
-
在线身份证号码提取生日工具
-
Online ID number extraction birthday tool
-
️野指针?悬空指针?️ 一文带你搞懂!
-
Field pointer? Dangling pointer? This article will help you understand!
-
HCNA Routing&Switching之GVRP
-
GVRP of hcna Routing & Switching
-
Seq2Seq实现闲聊机器人
-
【闲聊机器人】seq2seq模型的原理
随机推荐
- LeetCode 91. 解码方法
- Seq2seq implements chat robot
- [chat robot] principle of seq2seq model
- Leetcode 91. Decoding method
- HCNA Routing&Switching之GVRP
- GVRP of hcna Routing & Switching
- HDU7016 Random Walk 2
- [Code+#1]Yazid 的新生舞会
- CF1548C The Three Little Pigs
- HDU7033 Typing Contest
- HDU7016 Random Walk 2
- [code + 1] Yazid's freshman ball
- CF1548C The Three Little Pigs
- HDU7033 Typing Contest
- Qt Creator 自动补齐变慢的解决
- HALCON 20.11:如何处理标定助手品质问题
- HALCON 20.11:标定助手使用注意事项
- Solution of QT creator's automatic replenishment slowing down
- Halcon 20.11: how to deal with the quality problem of calibration assistant
- Halcon 20.11: precautions for use of calibration assistant
- “十大科学技术问题”揭晓!|青年科学家50²论坛
- "Top ten scientific and technological issues" announced| Young scientists 50 ² forum
- 求反转链表
- Reverse linked list
- js的数据类型
- JS data type
- 记一次文件读写遇到的bug
- Remember the bug encountered in reading and writing a file
- 单例模式
- Singleton mode
- 在这个 N 多编程语言争霸的世界,C++ 究竟还有没有未来?
- In this world of N programming languages, is there a future for C + +?
- es6模板字符
- js Promise
- js 数组方法 回顾
- ES6 template characters
- js Promise
- JS array method review
- 【Golang】️走进 Go 语言️ 第一课 Hello World
- [golang] go into go language lesson 1 Hello World