Refactoring in Coding
Make changes on existing code for subsequent and constant changes of requirement.
Reference:http://www.refactoring.com/catalog/index.html
Ways of Refactorings
- Add Parameter
- Change Bidirectional Association to Unidirectional
- Change Reference to Value
- Change Unidirectional Association to Bidirectional
- Change Value to Reference
- Collapse Hierarchy
- Consolidate Conditional Expression
- Consolidate Duplicate Conditional Fragments
- Convert Dynamic to Static Construction
- Convert Static to Dynamic Construction
- Decompose Conditional
- Duplicate Observed Data
- Eliminate Inter-Entity Bean Communication
- Encapsulate Collection
- Encapsulate Downcast
- Encapsulate Field
- Extract Class
- Extract Interface
- Extract Method
- Extract Package
- Extract Subclass
- Extract Superclass
- Form Template Method
- Hide Delegate
- Hide Method
- Hide presentation tier-specific details from the business tier
- Inline Class
- Inline Method
- Inline Temp
- Introduce A Controller
- Introduce Assertion
- Introduce Business Delegate
- Introduce Explaining Variable
- Introduce Foreign Method
- Introduce Local Extension
- Introduce Null Object
- Introduce Parameter Object
- Introduce Synchronizer Token
- Localize Disparate Logic
- Merge Session Beans
- Move Business Logic to Session
- Move Class
- Move Field
- Move Method
- Parameterize Method
- Preserve Whole Object
- Pull Up Constructor Body
- Pull Up Field
- Pull Up Method
- Push Down Field
- Push Down Method
- Reduce Scope of Variable
- Refactor Architecture by Tiers
- Remove Assignments to Parameters
- Remove Control Flag
- Remove Double Negative
- Remove Middle Man
- Remove Parameter
- Remove Setting Method
- Rename Method
- Replace Array with Object
- Replace Assignment with Initialization
- Replace Conditional with Polymorphism
- Replace Conditional with Visitor
- Replace Constructor with Factory Method
- Replace Data Value with Object
- Replace Delegation with Inheritance
- Replace Error Code with Exception
- Replace Exception with Test
- Replace Inheritance with Delegation
- Replace Iteration with Recursion
- Replace Magic Number with Symbolic Constant
- Replace Method with Method Object
- Replace Nested Conditional with Guard Clauses
- Replace Parameter with Explicit Methods
- Replace Parameter with Method
- Replace Record with Data Class
- Replace Recursion with Iteration
- Replace Static Variable with Parameter
- Replace Subclass with Fields
- Replace Temp with Query
- Replace Type Code with Class
- Replace Type Code with State/Strategy
- Replace Type Code with Subclasses
- Reverse Conditional
- Self Encapsulate Field
- Separate Data Access Code
- Separate Query from Modifier
- Split Loop
- Split Temporary Variable
- Substitute Algorithm
- Use a Connection Pool
- Wrap entities with session
Summerize:
Techniques that allow for more abstraction
- Encapsulate Field – force code to access the field with getter and setter methods
- Generalize Type – create more general types to allow for more code sharing
- Replace type-checking code with State/Strategy[6]
- Replace conditional with polymorphism [7]
Techniques for breaking code apart into more logical pieces
- Componentization breaks code down into reusable semantic units which present clear, well-defined, simple-to-use interfaces.
- Extract Class moves part of the code from an existing class into a new class.
- Extract Method, to turn part of a larger method into a new method. By breaking down code in smaller pieces, it is more easily understandable. This is also applicable to functions.
Techniques for improving names and location of code
- Move Method or Move Field – move to a more appropriate Class or source file
- Rename Method or Rename Field – changing the name into a new one that better reveals its purpose
- Pull Up – in OOP, move to a superclass
- Push Down – in OOP, move to a subclass
Refactoring in Coding的更多相关文章
- vs在线工具杂烩
http://visualstudiogallery.msdn.microsoft.com/site/search?f%5B0%5D.Type=RootCategory&f%5B0%5D.Va ...
- 使用 Code Snippet 简化 Coding
在开发的项目的时候,你是否经常遇到需要重复编写一些类似的代码,比如是否经常会使用 for.foreach ? 在编写这两个循环语句的时候,你是一个字符一个字符敲还是使用 Visual Studio 提 ...
- C# 使用 Code Snippet 简化 Coding
在开发的项目的时候,你是否经常遇到需要重复编写一些类似的代码,比如是否经常会使用 for.foreach ? 在编写这两个循环语句的时候,你是一个字符一个字符敲还是使用 Visual Studio 提 ...
- 【RefactoringCode】The description of the refactoring book
Last night the book named [Data Structure with Java Hubbed] was closed. When talked about the advant ...
- 如何优化coding
如何优化coding 前言 最近一直在做修改bug工作,修改bug花费时间最多的不是如何解决问题而是怎样快速读懂代码.如果代码写的好的,不用debug就可以一眼看出来哪里出了问题.实际上,我都要deb ...
- 如何将本地项目与coding.net/github上的项目绑定
得到coding.net/github项目的ssh协议地址 形如:·git@git.coding.net:wzw/leave-a-message.git· 在本地生成公钥 输入 ssh-keyge ...
- 将本地项目提交到coding上托管
1: 注册coding并新建项目test2:在终端 cd 到要提交的项目 使用git init创建.git文件夹3:使用git pull <项目地址>https的那个4:git a ...
- Block Markov Coding & Decoding
Block Markov coding在一系列block上进行.在除了第一个和最后一个block上,都发送一个新消息.但是,每个block上发送的码字不仅取决于新的信息,也跟之前的一个或多个block ...
- First Day:Starting My Coding Road
今天是2015年7月28日,星期二,晴,下午坐在科创园2楼的办公室里,窗明几净,继续我全新的Android之旅! 在调试和比较了N多IDE集成开发环境之后,最终决定在IDEA SDK环境下试试手,在已 ...
随机推荐
- BFS【bzoj1667】: [Usaco2006 Oct]Cows on Skates滑旱冰的奶牛
1667: [Usaco2006 Oct]Cows on Skates滑旱冰的奶牛 Description 经过跟Farmer John长达数年的谈判,奶牛们终于如愿以偿地得到了想要的旱冰鞋.农场上大 ...
- linux页表机制
每个进程都拥有一个自己的页表,在linux中,有一个页目录数组,这是分页机制的最高层,每个进程的页表对应其中的一个页目录项,通过cr3寄存器可以访问. 一个进程的页表,对应的页表项中对应页的物理地址. ...
- linux惊群
基本概念:子进程继承父进程环境和上下文的大部分内容的拷贝,其中就包括文件描述符表. 父进程fork出来的子进程,复制父进程的文件描述符.这些文件描述符fd是独立的,但是文件描述符指向的系统文件表项是唯 ...
- CF1117G Recursive Queries
题意:给定一个序列,定义[l, r]的最大值在m处,求f(l, r) = f(l, m - 1) + (r - l + 1) + f(m + 1, r).多次询问.100w. 解:考虑这个区间内每个数 ...
- BZOJ 3631 松鼠的新家 树上差分
我猜会有智障说直接链剖+线段树…(希望没有) From RYC's 课件 然鹅我并不反对树剖...我是智障...QAQ 好吧还是树上差分:设 a[i]=u.a[i+1]=v ++w[u],++w[v] ...
- 1005 继续(3n+1)猜想(25 分)
卡拉兹(Callatz)猜想已经在1001中给出了描述.在这个题目里,情况稍微有些复杂. 当我们验证卡拉兹猜想的时候,为了避免重复计算,可以记录下递推过程中遇到的每一个数.例如对 n=3 进行验证的时 ...
- POJ:2976 Dropping tests(二分+最大化平均值)
Description In a certain course, you take n tests. If you get ai out of bi questions correct on test ...
- Hibernate JPA 如何使用SQL文直接查询
对于复杂SQL,可以直接调用native sql来是实现 public List<Partner> findPartners() { List<Partner> partner ...
- 在x64平台上调试依赖于x86的WCF服务
根据微软官方的解释,WCF(之前的版本名为“Indigo”)是使用托管代码建立和运行面向服务(Service Oriented)应用程序的统一框架.它使得开发者能够建立一个跨平台的安全.可信赖.事务性 ...
- thinkPHP5.0 volist标签理解
{volist name="list" id="vo" offset="5" length="10"} .... {/v ...