书籍 Refactoring的封面
书籍介绍
Refactoring is about improving the design of existing code. It is the process of changing a software system in such a way that it does not alter the external behavior of the code, yet improves its internal structure. With refactoring you can even take a bad design and rework it into a good one. This book offers a thorough discussion of the principles of refactoring, including where to spot opportunities for refactoring, and how to set up the required tests. There is also a catalog of more than 40 proven refactorings with details as to when and why to use the refactoring, step by step instructions for implementing it, and an example illustrating how it works The book is written using Java as its principle language, but the ideas are applicable to any OO language.
用户评论
Improving the design with the existing code
可惜不是js,以及kindle看code真是看不进去
能把这些规律提炼出来确实很牛,可惜匆匆一读,所得不多。
工作一年好代码看多了雷也踩了不少,再读这本就感觉没那么醍醐灌顶了,可能上学时读会更惊艳吧。(然而这也只是马后炮,上学时赶due基本不会想着refactor,而且连踩雷的机会也屈指可数 ¯\_(ツ)_/¯
值得一读。这类书都有点太细节,太琐碎。
当大牛在手把手教你认真对待每一行代码的时候 你还能说什么呢
1 Extract function和split phase 我太赞同了。 其实还是本质还是鼓励small function,更清晰。 2 simplifying conditional logic 最喜欢的三个tool 2.1 decompose conditional 还是使用extract function,让复杂条件更清晰明了。 2.2 consolidate conditional logic 相同逻辑使用一个if 2.3 replace nested conditional with guard clause if else的层次不要太深,影响阅读,影响理解。用简洁的几个if搞定。 3 抽象 抽象降低理解的困难度。 最重要的一点,重构的前提是单元测试。
For much of the history of software development, most people believed that we design first, and only when done with design should we code. Over time, the code will be modified, and the integrity of the system—its structure according to that design—gradually fades. The code slowly sinks from engineering to hacking.
内容是okay 的,但中文翻译还是不太行。