Putting Nested Classes In Separate Files

不打扰是莪最后的温柔 提交于 2019-11-29 21:39:03

问题


I have a file with nested classes, but it's becoming long enough to be unreadable. Is there a way I can break out the nested classes into separate files?


回答1:


Use the right tools.




回答2:


I'm afraid not.
As an alternative, you could consider converting some of them to plain Java classes: although nested classes increase encapsulation, you can certainly create good OO design without them.

My two cents.




回答3:


Write unit-tests to cover the code you are going to refactor.

Then use refactoring tools, e.g. Eclipse/JDT to extract each class. Run the tests for each refactoring job.

For extra fun, you can do this without the unit tests.



来源:https://stackoverflow.com/questions/3645047/putting-nested-classes-in-separate-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!