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环境下试试手,在已 ...
随机推荐
- Tensorflow实践
确定文件的编码格式 # -*- coding : utf-8 -*- 引入tensorflow库 import tensorflow as tf 定义常量 hw=tf.contant("he ...
- Eclipse使用Ctrl+C和Ctrl+V复制粘贴时总是卡顿
Eclipse使用Ctrl+C和Ctrl+V复制粘贴时总是卡顿,解决办法: 更改打开代码超链接按键Ctrl为Alt: Window -> Preferences -> General -& ...
- tomcat的热部署配置
1.什么是tomcat热部署? 所谓的tomcat热部署,就是在不重启tomcat服务器的前提下,将自己的项目部署到tomcat服务器中,这种方式是非常方便的,也称之为“开发即用”,热部署分为手动热部 ...
- Kibana6.x.x——导航权限控制入门
按如下图所示设置: 用该用户登录后,界面如图所示: 但遗憾的是,根据官方论坛的说法,其它的导航隐藏控制,暂时还不支持. 参考:https://discuss.elastic.co/t/hide-ina ...
- 基本数据类型 list and tuple 04
列表和元组 一,列表 1.列表 由[]括起来 可以存放各种数据类型: 存放量比较大 2.列表的索引和切片 列表也有索引 lst [i] i 即列表中各元素的位置 2.1列表的切片 lst[star ...
- HikariPool连接池的使用
HikariDataSource datasource= new HikariDataSource( xxxx ); Connection cn = datasource.getConnection( ...
- CPU的CAS操作
https://blog.csdn.net/qq_35492857/article/details/78471032 https://www.cnblogs.com/gdjdsjh/p/5076815 ...
- 8php字符串的方法
<?php/** * Created by PhpStorm. * User: DY040 * Date: 2017/9/8 * Time: 16:46 *//*php也有转义字符/*///ec ...
- Spring---数据缓存(未完待续)
1.为什么需要数据缓存? 程序的瓶颈大都在数据库,而内存的速度是远远大于硬盘的,当我们需要重复读取相同数据时,一次又一次的请求数据库或者远程服务,导致大量的时间浪费在数据库或者 远程服务上,导致程序性 ...
- ERROR:105: Unable to locate a modulefile for 'xxx'
查看可用的 module:module avail 将xxx替换为屏幕输出中已有的模块.