Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • You are right, the circular dependency is problematic. One could resolve this by mimicking the Builder's build() method from the example you provided and setting the PersonImpl's fields to protected. But then one would need to keep the package very small to keep the class effectively immutable. Commented Jul 15, 2014 at 7:21
  • Not sure if the circular dependency is a problem at all. A use case for this design might be that you create a nicer API -- think DSL. For example, the Map.of() family of static methods of the java.util.Map interface will create concrete maps using other top-level classes that in turn depend on the Map interface. Not a problem at all. Using Map.of() to create an empty map is certainly a nicer API than having to resort to something like MapFactory.create(). Commented May 13, 2020 at 19:04