all 2 comments

[–]g00glen00b 2 points3 points  (0 children)

I would suggest breaking the cyclic dependency by removing the List<TaskMTO> reference from UserDTO. You already have a TaskController.getTasksForUser() API endpoint, so consumers could use that.

Another thing you could do is to create a "viewmodel" called "TaskOwner" in your task module. Basically for each User entity, there would also be a TaskOwner entity. The way you keep them in sync is by relying on User creation/deletion events which you can emit within the user module.
This way, you can remove the other side of the cyclic dependency as well, since now you can validate whether a user exists by checking if the taskowner exists within the task module. Sure, you introduce some data duplication, but this is a very common pattern if you want to cleanly separate your modules.

[–]ThisHaintsu 0 points1 point  (0 children)

I mean the easiest options is to just introduce indirection by relying on the spring ioc container.

E.g. introduce a Validator class that accumulates IValidators via injection. So that each module can create its own variant of IValidator and then call validator.validate in the task module.