Giter Club home page Giter Club logo

book-refactor-golang's Introduction

Refactor with Go

《重构》一书中的Java 示例修改为Golang 示例

下载

代码

git clone --depth=1 https://github.com/nxlsBoy/book-refactor-golang.git

PDF

请支持正版图书 - 下载链接

目录

第八章-重新组织数据

从数据结构层面去重构代码

Patern Expression Progress
Self Encapsulate Field 自我封装 -
将直接访问成员字段的方式修改为间接访问
Replace Data Value with Object 结构对象替换简单类型 -
将简单数据类型替换为结构类型,易于扩展
Change Value to Reference 值类型替换为引用类型 -
修改一处, 即可修改其他所有引用的地方
Change Reference to Value
Replace Array with Object
Duplicate Observed Data
Change Unidirectional Association to Bidirectional
Change Bidirectional Association to Unidirectional
Replace Magic Number with Symbolic Constant
Encapsulate Field
Encapsulate Collection
Replace Record with Data Class
Replace Type Code with Class
Replace Type Code with Subclasses
Replace Type Code with State/Strategy
Replace Subclass with Fields

第十章-简化函数调用

针对函数调用的优化

Patern Expression Prograss
Rename Method 修改函数名
Add Parameter 添加参数
Remove Parameter 移除参数
Separate Query from Modifier 查询与修改函数独立
Parameterize Method 让函数携带参数
Replace Parameter with Explicit Methods 以明确函数取代参数
Preserve Whole Object 保持对象完整
Replace Parameter with Methods 以函数取代参数
Introduce Paramter Object 引入参数对象
Remove Setting Method 溢出设置值函数
Hide Method 隐藏函数
Replace Constructor with Factory Method 工厂函数取代构造函数
Encapsulate Downcast 封装向下转型
Replace Error Code with Exception 以异常取代错误骂
Replace Exception with Test 以测试取代异常

book-refactor-golang's People

Contributors

muzig1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

book-refactor-golang's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.