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. Tensorflow实践

    确定文件的编码格式 # -*- coding : utf-8 -*- 引入tensorflow库 import tensorflow as tf 定义常量 hw=tf.contant("he ...

  2. Eclipse使用Ctrl+C和Ctrl+V复制粘贴时总是卡顿

    Eclipse使用Ctrl+C和Ctrl+V复制粘贴时总是卡顿,解决办法: 更改打开代码超链接按键Ctrl为Alt: Window -> Preferences -> General -& ...

  3. tomcat的热部署配置

    1.什么是tomcat热部署? 所谓的tomcat热部署,就是在不重启tomcat服务器的前提下,将自己的项目部署到tomcat服务器中,这种方式是非常方便的,也称之为“开发即用”,热部署分为手动热部 ...

  4. Kibana6.x.x——导航权限控制入门

    按如下图所示设置: 用该用户登录后,界面如图所示: 但遗憾的是,根据官方论坛的说法,其它的导航隐藏控制,暂时还不支持. 参考:https://discuss.elastic.co/t/hide-ina ...

  5. 基本数据类型 list and tuple 04

    列表和元组 一,列表 1.列表 由[]括起来 可以存放各种数据类型:  存放量比较大 2.列表的索引和切片  列表也有索引 lst [i] i 即列表中各元素的位置 2.1列表的切片 lst[star ...

  6. HikariPool连接池的使用

    HikariDataSource datasource= new HikariDataSource( xxxx ); Connection cn = datasource.getConnection( ...

  7. CPU的CAS操作

    https://blog.csdn.net/qq_35492857/article/details/78471032 https://www.cnblogs.com/gdjdsjh/p/5076815 ...

  8. 8php字符串的方法

    <?php/** * Created by PhpStorm. * User: DY040 * Date: 2017/9/8 * Time: 16:46 *//*php也有转义字符/*///ec ...

  9. Spring---数据缓存(未完待续)

    1.为什么需要数据缓存? 程序的瓶颈大都在数据库,而内存的速度是远远大于硬盘的,当我们需要重复读取相同数据时,一次又一次的请求数据库或者远程服务,导致大量的时间浪费在数据库或者 远程服务上,导致程序性 ...

  10. ERROR:105: Unable to locate a modulefile for 'xxx'

    查看可用的 module:module avail 将xxx替换为屏幕输出中已有的模块.