(Java) 包组织有最佳实践吗? [关闭] - Are there best practices for (Java) package organization? [closed]

10/14 12:33
阅读数 0

问题:

Closed . 关闭 This question is opinion-based . 这个问题是基于意见的 It is not currently accepting answers. 它目前不接受答案。

Want to improve this question?想改善这个问题吗? Update the question so it can be answered with facts and citations by editing this post .更新问题,以便通过编辑这篇文章用事实和引文来回答问题。

Closed 6 years ago . 6年前关闭。

A little while ago, I saw a question answered here regarding the fine-grained organization of java packages.不久前,我看到这里回答了一个关于 java 包的细粒度组织的问题。 For example, my.project.util , my.project.factory , my.project.service , etc.例如, my.project.utilmy.project.factorymy.project.service等。

I can't find it now, so I may as well ask the question.我现在找不到了,所以我也可以问这个问题。

Are there best practices with regards to the organization of packages in Java and what goes in them?是否有关于 Java 包组织的最佳实践以及它们的内容?

How do you organize your classes in your Java project?您如何组织 Java 项目中的类?

For instance, a project I'm working on with a few people has a package called beans.例如,我正在与几个人合作的一个项目有一个名为 beans 的包。 It started out being a project containing simple beans, but has ended up (through poor experience and lack of time) containing everything (almost).它开始是一个包含简单 bean 的项目,但最终(由于糟糕的经验和缺乏时间)包含所有内容(几乎)。 I've cleaned them up a little, by putting some factory classes in a factory package (classes with static methods that create beans) but we have other classes that do business logic and others that do simple processing (not with business logic) like retrieving a message for a code from a properties file.我已经清理了一点,通过将一些工厂类放在工厂包中(具有创建 bean 的静态方法的类),但我们还有其他类执行业务逻辑和其他执行简单处理(不使用业务逻辑)的类,例如检索来自属性文件的代码消息。

Your thoughts and comments are appreciated.感谢您的想法和评论。


解决方案:

参考一: https://en.stackoom.com/question/DXIo
参考二: https://stackoom.com/question/DXIo
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部