当前位置:网站首页>IEDA refactor的用法
IEDA refactor的用法
2022-07-02 18:13:00 【thoughtCodes】
IEDA refactor的用法
- 目录
- 概述
- 设计思路
- 实现思路分析
- 1.Refacot this
- 2.rename
- 3.rename file
- 4.change sinnature
- 5.Edit pro value
- 5.Type m
- 5.make static
- 6.convert to instance method
- 7.move class/member
- 8.copy class
- 9.safe delete
- 6.Extract
- inline super class
- Invert bolean
- find and repalce duliate:
- pull up member:
- pull down member:
- user inteface:
- inherit from replace
- remove middlman
- wrap method return value
- encapsulate Fields:
- replace temp with query
- replace constrct with factory
- replace constructor with build
- genirity
- migrate
- interliatelize
- migrate to anroidRx
- 使用顺序和方法
- 拓展实现
- 性能参数测试:
- 参考资料和推荐阅读
Survive by day and develop by night.
talk is cheap, show me the code,make a better result.
目录

概述
一直想写个这个用法,之前也用过,只是用了一部分,现在概述一下,当我们按照业务需求写好对应的代码时,这点是非常重要的。
需求:
设计思路
实现思路分析
1.Refacot this
选择对象,右键弹出建议列表,选择重构即可。
2.rename
这个比较简单,使用命名规范,重命名即可。
3.rename file
在当前选中文件重命名即可
4.change sinnature
通常是改动方法,改变方法参数。
5.Edit pro value
改变属性数值,目录对象没有,可能是pro文件有
5.Type m
类型相关
5.make static
操作对象,目录没有,方法对象有,应该是将方法变成static 的。
6.convert to instance method
将方法转成static 的,和5有什么区别呢?
7.move class/member
移动类的目录结构的
8.copy class
将文件copy到指定的目录,本地目录失败。
9.safe delete
这个比较简单,安全删除,文件待待删除文件不存在了。
6.Extract
variable
目前选择文件失败,选择的应该是表达式:
抽取表达式为常量:
constant

Filed
选择变量,属性名失败,同理选择的是一个表达式:
但是注意的是这个IEDA没有自动的将逻辑抽进去,就是将表达式作为一个成员变量处理了。
paraeter
选择单一变量名称或函数列表失败。应该选择的是表达式:
选择前:
重构后:
但是IEDA在逻辑上也没有对应的工程抽取。
object
选择单一变量名称或函数列表失败。
method:

选择具体的方法内的代码行,抽取方法:
Type parameter
选择方法列表无效。
Method object

将调用方法变成内部类和匿名类:
delegate

通常是生成一个新类,作为委派对象。由委派对象调用。
interface:

结果:
super class
先选择:
结果:
将抽取int 属性和增加对应的extends 类:
inline super class
选择父类:经过分析引用之后:
结果:
Invert bolean
暂时还不知道
find and repalce duliate:

pull up member:
pull down member:
选择对应的父类,抽取
user inteface:
选择使用的方法,进行分析,可以使用接口代替
inherit from replace

生成一个委派类,在内部的实现了一个接口。
remove middlman
服务类完全变成了“中间人”,此时你就应该让客户直接调用受托类。
wrap method return value
封装方法
encapsulate Fields:

replace temp with query
用查询取代临时结果
replace constrct with factory
用工厂方法取代构造方法,
选择方法行: 
replace constructor with build
用builder模式构造构造方法:
genirity
java 中的泛型,这个资料很少
migrate
迁移,一般提供了javaex,junit,swing的迁移选项:
interliatelize
在线的
migrate to anroidRx
迁移到对应的androidRx:
以上从基本的对象出发大概就这么多,针对不同的对象出现的菜单也不是一样。
使用顺序和方法
如下从粒度的角度,看下:
主要是
1.varibale,constant,filed等操作
2.function 内部的级别,主要是抽取参数,对象等。
3.选择多行的就是method,或method对象(作为匿名类,内部类处理)
其实也是抽取菜单的不同。
接着就是基于class文件级别的重构:
对单类来说:
1.删除,移动,删除等
2.较为更高的级别:重命名等。
这部分可以有操作系统管理,也仅是提供了另一个编辑入口。
多类来说:设计角度来说:通常是3个:
delagate,interface,superclass,
首先选择的对象有extends,impl 关键字等,这部分才能实现
对于一个成熟项目来说,实际来书extends好像用的多一下。
对于其关系展开的。
接着就是一些pattern的应用了最佳实践了。
如builder,factorypattern.会生成一个builder文件和调用文件。
接着就是class lib 级别的了,
无非就是jar 迁移,class 泛型:
以上对Java开发基本够了,
如果还有那就是系统间文件转换了如:
转成迁移到androidX文件。
至此分析完毕。
拓展实现
- 入门级实现:
- 部分源码实现.
- 源码实现
理论提供了依据。一般优化到pattern 层就差不多了。
性能参数测试:
无
参考资料和推荐阅读
欢迎阅读,各位老铁,如果对你有帮助,点个赞加个关注呗!~
边栏推荐
- R language uses lrtest function of epidisplay package to perform likelihood ratio test on multiple GLM models (logisti regression). Compare whether the performance of the two models is different, and
- Yunna | why use the fixed asset management system and how to enable it
- 2022 software engineering final exam recall Edition
- 仿京东放大镜效果(pink老师版)
- Learn the knowledge points of eight part essay ~ ~ 1
- Talk about the design of red envelope activities in e-commerce system
- R language ggplot2 visualization: visualize the line chart and add customized X-axis label information to the line chart using labs function
- [100 cases of JVM tuning practice] 01 - introduction of JVM and program counter
- R语言dplyr包na_if函数把向量数值中的控制转化为缺失值NA、按照映射规则把指定内容转化为缺失值NA
- juypter notebook 修改默认打开文件夹以及默认浏览器
猜你喜欢

Stm32g0 USB DFU upgrade verification error -2

Tutorial (5.0) 10 Troubleshooting * fortiedr * Fortinet network security expert NSE 5

Installation of thingsboard, an open source IOT platform

Web2.0的巨头纷纷布局VC,Tiger DAO VC或成抵达Web3捷径

论文导读 | 机器学习在数据库基数估计中的应用

中国信通院《数据安全产品与服务图谱》,美创科技实现四大板块全覆盖

juypter notebook 修改默认打开文件夹以及默认浏览器

【JVM调优实战100例】03——JVM堆调优四例

论文导读 | 关于将预训练语言模型作为知识库的分析与批评

医院在线问诊源码 医院视频问诊源码 医院小程序源码
随机推荐
Learning summary of MySQL advanced 6: concept and understanding of index, detailed explanation of b+ tree generation process, comparison between MyISAM and InnoDB
数据降维——主成分分析
Date tool class (updated from time to time)
[100 cases of JVM tuning practice] 02 - five cases of virtual machine stack and local method stack tuning
MySQL advanced learning summary 7: MySQL data structure - Comparison of hash index, AVL tree, B tree and b+ tree
The difference between SLC, MLC, TLC and QLC NAND SSD: which is better?
R语言dplyr包filter函数筛选dataframe数据、如果需要筛选的数据列(变量)名称中包含引号则需要使用!!sym语法处理、否则因为无法处理引号筛选不到任何数据
ORA-01455: converting column overflows integer datatype
R语言dplyr包na_if函数把向量数值中的控制转化为缺失值NA、按照映射规则把指定内容转化为缺失值NA
Competence of product manager
R语言使用epiDisplay包的lrtest函数对多个glm模型(logisti回归)执行似然比检验(Likelihood ratio test)对比两个模型的性能是否有差异、广义线性模型的似然比检
Qpropertyanimation use and toast case list in QT
PHP非对称加密方法私钥及公钥加密解密的方法
【JVM调优实战100例】02——虚拟机栈与本地方法栈调优五例
yolov3 训练自己的数据集之生成train.txt
Looking for innocence in New York -- a beautiful day at the discovery center of Legoland, New Jersey
Hospital online inquiry source code hospital video inquiry source code hospital applet source code
Excel如何进行隔行复制粘贴
R language uses Cox of epidisplay package Display function obtains the summary statistical information of Cox regression model (risk rate HR, adjusted risk rate and its confidence interval, P value of
Obligatoire pour les débutants, cliquez sur deux boutons pour passer à un contenu différent