Agrim Pathak
Agrim Pathak

Reputation: 3207

Java interface and class organization convention within packages

I've seen the organization below, but was wondering if there are any established conventions or helpful advice for organizing classes and interfaces?

Upvotes: 4

Views: 676

Answers (1)

Ned
Ned

Reputation: 957

There is no hard and fast rule and your mileage may vary...

However, I recommend keeping related public interfaces and implementation code in the same package. In that way, the interfaces, enums, constants, factory classes, or whatever else needs to be publicly available is public, while implementation classes can be mostly or entirely private or only package visible. Putting implementation classes in a separate package will force some details to be public which would not otherwise have to be exposed.

Upvotes: 2

Related Questions