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)
有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top