Make changes on existing code for subsequent and constant changes of requirement.

Reference:http://www.refactoring.com/catalog/index.html

Ways of Refactorings

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的更多相关文章

  1. vs在线工具杂烩

    http://visualstudiogallery.msdn.microsoft.com/site/search?f%5B0%5D.Type=RootCategory&f%5B0%5D.Va ...

  2. 使用 Code Snippet 简化 Coding

    在开发的项目的时候,你是否经常遇到需要重复编写一些类似的代码,比如是否经常会使用 for.foreach ? 在编写这两个循环语句的时候,你是一个字符一个字符敲还是使用 Visual Studio 提 ...

  3. C# 使用 Code Snippet 简化 Coding

    在开发的项目的时候,你是否经常遇到需要重复编写一些类似的代码,比如是否经常会使用 for.foreach ? 在编写这两个循环语句的时候,你是一个字符一个字符敲还是使用 Visual Studio 提 ...

  4. 【RefactoringCode】The description of the refactoring book

    Last night the book named [Data Structure with Java Hubbed] was closed. When talked about the advant ...

  5. 如何优化coding

    如何优化coding 前言 最近一直在做修改bug工作,修改bug花费时间最多的不是如何解决问题而是怎样快速读懂代码.如果代码写的好的,不用debug就可以一眼看出来哪里出了问题.实际上,我都要deb ...

  6. 如何将本地项目与coding.net/github上的项目绑定

      得到coding.net/github项目的ssh协议地址 形如:·git@git.coding.net:wzw/leave-a-message.git· 在本地生成公钥 输入 ssh-keyge ...

  7. 将本地项目提交到coding上托管

    1:   注册coding并新建项目test2:在终端 cd 到要提交的项目  使用git init创建.git文件夹3:使用git pull  <项目地址>https的那个4:git a ...

  8. Block Markov Coding & Decoding

    Block Markov coding在一系列block上进行.在除了第一个和最后一个block上,都发送一个新消息.但是,每个block上发送的码字不仅取决于新的信息,也跟之前的一个或多个block ...

  9. First Day:Starting My Coding Road

    今天是2015年7月28日,星期二,晴,下午坐在科创园2楼的办公室里,窗明几净,继续我全新的Android之旅! 在调试和比较了N多IDE集成开发环境之后,最终决定在IDEA SDK环境下试试手,在已 ...

随机推荐

  1. P4841 城市规划 FFT+生成函数

    \(\color{#0066ff}{ 题目描述 }\) 刚刚解决完电力网络的问题, 阿狸又被领导的任务给难住了. 刚才说过, 阿狸的国家有n个城市, 现在国家需要在某些城市对之间建立一些贸易路线, 使 ...

  2. 【三支火把】--- shell脚本中变量的类型及作用域

    一直对shell脚本有一种特殊的感觉,因此花了一段时间学习,本人擅长C语言编程,深受C语言荼毒,在学习其他任何类似于编程语言的东东的时候,都会不自觉的与C进行对比,因此对于shell中的变量的作用域一 ...

  3. Hadoop源码分析之产生InputSplit文件过程

        用户提交 MapReduce 作业后,JobClient 会调用 InputFormat 的 getSplit方法 生成 InputSplit 的信息.     一个 MapReduce 任务 ...

  4. 2-29 while

    do while for

  5. Dijkstra算法图文详解

    Dijkstra算法 Dijkstra算法算是贪心思想实现的,首先把起点到所有点的距离存下来找个最短的,然后松弛一次再找出最短的,所谓的松弛操作就是,遍历一遍看通过刚刚找到的距离最短的点作为中转站会不 ...

  6. HDU 4352 区间的有多少个数字满足数字的每一位上的数组成的最长递增子序列为K(数位DP+LIS)

    题目:区间的有多少个数字满足数字的每一位上的数组成的最长递增子序列为K 思路:用dp[i][state][j]表示到第i位状态为state,最长上升序列的长度为k的方案数.那么只要模拟nlogn写法的 ...

  7. 09-排序2 Insert or Merge (25 分)

    According to Wikipedia: Insertion sort iterates, consuming one input element each repetition, and gr ...

  8. day31 管道 进程池 数据共享

    1.    管道(了解) #创建管道的类: Pipe([duplex]):在进程之间创建一条管道,并返回元组(conn1,conn2),其中conn1,conn2表示管道两端的连接对象,强调一点:必须 ...

  9. ubuntu中误删/var/lib/dpkg/info的补救方法

    今晚在ubuntu上安装一个软件时,出现这样的错误提示:E: Sub-process /usr/bin/dpkg returned an error code (1)然后在网上找了查找问题原因及解决方 ...

  10. join合并字符串时使用生成器表达式

    data=['11','pp','aa'] ','.join(str(d) for d in data)