当前位置:网站首页>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 dplyr package Na_ The if function converts the control in the vector value into the missing value Na, and converts the specified content into the missing value Na according to the mapping r
- R语言ggplot2可视化:gganimate包创建动态柱状图动画(gif)、使用transition_states函数在动画中沿给定维度逐步显示柱状图
- QT中的QPropertyAnimation使用和toast案列
- 数字滚动带动画
- How performance testing creates business value
- Progress-进度条
- 虚拟机初始化脚本, 虚拟机相互免秘钥
- Date tool class (updated from time to time)
- Markdown基础语法
- [test development] software testing - concept
猜你喜欢
仿京东放大镜效果(pink老师版)
STM32G0 USB DFU 升级校验出错-2
Juypter notebook modify the default open folder and default browser
Yolov3 trains its own data set to generate train txt
Mysql高级篇学习总结8:InnoDB数据存储结构页的概述、页的内部结构、行格式
The difference between interceptor and filter
【JVM调优实战100例】02——虚拟机栈与本地方法栈调优五例
新手必看,点击两个按钮切换至不同的内容
9D电影是怎样的?(+维度空间常识)
[100 cases of JVM tuning practice] 03 -- four cases of JVM heap tuning
随机推荐
Introduction to the paper | analysis and criticism of using the pre training language model as a knowledge base
Emmet basic syntax
Binary operation
What is 9D movie like? (+ common sense of dimension space)
潇洒郎:彻底解决Markdown图片问题——无需上传图片——无需网络——转发给他人图片无缺失
全志A33使用主线U-Boot
Reduce -- traverse element calculation. The specific calculation formula needs to be passed in and combined with BigDecimal
UML class diagram
教程篇(5.0) 09. RESTful API * FortiEDR * Fortinet 网络安全专家 NSE 5
Tips for material UV masking
数据降维——因子分析
Memory management of C
reduce--遍历元素计算 具体的计算公式需要传入 结合BigDecimal
STM32G0 USB DFU 升级校验出错-2
日期工具类(不定时更新)
R language dplyr package Na_ The if function converts the control in the vector value into the missing value Na, and converts the specified content into the missing value Na according to the mapping r
When converting from list to map, if a certain attribute may cause key duplication and exceptions, you can set the way to deal with this duplication
【JVM调优实战100例】02——虚拟机栈与本地方法栈调优五例
Crypto usage in nodejs
数据降维——主成分分析