对 Java 类进行分组
当我使用 Eclipse 时,我使用大量 Java 类(尤其是在使用抽象工厂设计模式时),并且我需要一种方法来直观地将属于一起的类分组(从接口扩展或实现的不同类混合在一起)。
我需要一种方法来对扩展同一类或实现相同接口的类进行分组,这样我就不会失去心理健康。几天前我开始使用 Eclipse 和 Java,所以我确信我缺少一些东西来完成我需要的事情......
When I'm using Eclipse i work with lots of Java classes (especially when working with abstract factory design pattern) and I need a way to visually group classes belonging together (different classes extended or implemented from interfaces get mixed together).
I need a way to group classes that extend the same class or implement the same interface so I don't lose my mental health. I started using Eclipse and Java few day ago, so I'm sure I'm missing something to do what i need...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Eclipse 有一个非常方便的功能,它允许您准确地查看哪些类扩展(或实现)任何类/接口。
选择您感兴趣的超类/接口/方法,然后按 CTRL-T。这将显示一个弹出对话框,其中包含实现或扩展类层次结构。再次按下 CTRL-T 将显示超类层次结构(反向)
Eclipse has a very handy feature which allows you to see exactly which classes extend (or implement) any class/interface.
Select the superclass/interface/method you are interested in, and press CTRL-T. This will show a popup dialog with the implementing or extending class hierarchy. CTRL-T again will show the super class hierarchy (reverse direction)
您可以将属于同一事件的类组织到不同的包中。例如: com.abc.birds 应包含仅与鸟类相关的类。com.abc. human 应包含仅与人类相关的所有类。
You can organize your classes belonging to same event into different packages.for example: com.abc.birds should contain classes related to birds only.com.abc.human should contain all classes related to human only.
您是否已将课程组织在包中?这正是包的用途。如果将它们组织在包中,您将在 Eclipse Package Explorer 中对属于一起的类有一个很好的视图。
进一步阅读:
Have you organized your classes in packages? This is precisely what packages are for. If you organize them in packages, you'll have a nice view of the classes belonging together in the Eclipse Package Explorer.
Further reading:
将类导入某种 UML 工具中。有几个免费的,包括 JUDE。或者看看Eclipse有没有UML插件。
Import the classes into a UML tool of some kind. There are several free ones out there, including JUDE. Or see if Eclipse has a UML plug-in.