문제

I'm trying to make a small crud application using swing, with Authentication features and GUI.

Can you give me the right organization and naming of my packages ??

도움이 되었습니까?

해결책

There's no hard and fast rule, but the rule of thumb is to start with your company's domain name in reverse:

com.mycompany

Then add on the project:

com.mycompany.project

This ensures you're unlikely to have clashes between your classes and those from the libraries you depend on.

Then personally I try break things down by their functional groups, for example

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

Within those packages, I might have further group but that would be very specific to the project.

The important thing is to be consistent across your project.

다른 팁

Short answer: One package per module/feature, possibly with sub-packages. Put closely related things together in the same package. Avoid circular dependencies between packages.

Long answer: I agree with most of this article

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top