(Basic - Arch/Design) Is it normal to create setter methods in Entity Class with Domain logic?
Is it normal to put domain logic inside setter methods in an Entity class? Or a bad idea?
For eg, I have a Domain Service that contains business validations and other domain logic. I also have Application Services that handle different use-case scenarios. Right now, my Entity has a public setStatus() method, which means anyone can call it and bypass the validations in the Domain Service. I cannot make setStatus() protected because the Entity and the Service are in different packages.
What’s the standard approach Spring developers usually follow here?
Do people typically move the logic into the setter/entity method instead of the Domain Service?
What if the logic really belongs in the Domain Service because it depends on external dependencies or other services?