I have a a class course which uses the state pattern to model the state of a course. A course starts as a draft, can then be handed in to be approved by an admin. If the course was approved it can be published via the rest api. Before being published courses may be canceled or deleted by the creator itself. If the course was already published only admins should be able to edit the course.
Until now I ended up with a mixture of conditionals to verify a certain user has required permission to change the state of the course and state pattern to verify correct state transitions.
Is there a way to integrate this behaviour in a single pattern? As I'm using DDD integrating permissions directly into the business rules this would violate DDD rules if I'm right
Aucun commentaire:
Enregistrer un commentaire