首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 其他相关 >

Move Class - 挪动类

2013-03-21 
Move Class -- 移动类Move ClassRefactoring contributed by Gerard M. DavisonYou have a class that is

Move Class -- 移动类

Move Class

Refactoring contributed by Gerard M. Davison

You have a class that is in a package that contains other classes that it is not related to in function.

在包里有一个类和其他的类在功能上没啥关系。

Move the class to a more relevant package. Or create a new package if required for future use.

将这个类移动到相关的包里,或者创建一个将来可能会使用的包,并移动到里面。

Move Class - 挪动类

// A class literal, this will be found by the compiler.public Class m_utils = org.davison.util.StringUtils.class;// A dynamically loaded classpublic Class m_utils = Class.forName("org.davison.util.StringUtils");// A loaded resource bundlepublic ResourceBundle m_bundle = ResourceBundle.getBundle(   "org.davison.util.StringUtils");

One all static and dynamic cases have been dealt with, and all unit tests have run. The refactoring is complete.

当所有的静态引用和动态引用解决后,测试一下。重构就算完成了。


通常在Ecplise中,选中要移动的类,拖动到待移动的包中,Ecplise会查找所有的引用点,并进行修改。但是一定还要根据作者的重构步骤,检查下待移动类的动态代码,将其修改掉,还有单元测试相关连的也需要修改。

热点排行