Question

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

  • [domain].[name]
    • foo
      • impl (contains classes with abstract and concrete implementations)
      • intf (contains interfaces)
Was it helpful?

Solution

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.

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