Question

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 ??

Was it helpful?

Solution

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top