On Tue, Jul 5, 2022 at 11:46 AM Andrus Adamchik <aadamc...@gmail.com> wrote:
> Now that "default" implementations of interface methods are possible... > This sounds more interesting to me. I'm assuming you mean a separate interface per callback? Something like PostAddLifecyleCallback? You wouldn't need a default method implementation in that case. If you implement the interface, you should implement the method. It'll also be easier for Cayenne to test if the object implements a given lifecycle interface. If you group them all into a single LifecycleCallbacks interface, though, then yeah, you'd want default methods and call them blindly (they would either do nothing -- the default -- or run the object's lifecycle code). One possible advantage of annotations is you could include several @PostAdd-annotated methods, but then you'd potentially have calling order issues. When we did post-adds, we'd put all the changes in one method or have that one method call smaller ones in-order. I think I'd prefer the certainty of a single method (via interface) than random annotation orderings. Of course, can always throw a runtime error if more than one method has the same annotation, but I think not having that error at runtime is a better approach.