在java标准crud应用程序中正确组织包

时间:2014-04-09 15:53:33

标签: java swing packages

我尝试使用 swing ,使用身份验证功能和GUI来制作小型crud应用程序。

你能否给我正确的组织和我的包的命名 ??

2 个答案:

答案 0 :(得分:0)

简答:每个模块/功能一个包,可能带有子包。将密切相关的东西放在同一个包中。避免包之间的循环依赖。

答案很长:I agree with most of this article

答案 1 :(得分:0)

没有严格的规则,但经验法则是从公司的域名开始反过来:

com.mycompany

然后添加项目:

com.mycompany.project

这可以确保您的课程与您所依赖的图书馆之间不会发生冲突。

然后我个人尝试按功能组分解,例如

com.mycompany.project.domain        // contains the business domain classes
com.mycompany.project.io            // contains the classes that deal with network or file-system
com.mycompany.project.persistence   // contains the classes that handle persistence of the business domain classes
com.mycompany.project.ui            // contains the user interface related classes

在这些软件包中,我可能会有更多的组,但这对项目非常具体。

重要的事情是在整个项目中保持一致。