mercredi 2 janvier 2019

DDD approach Where to enforce business rules?

New to DDD I have a simple case a I would like to model using DDD approach

2 entities Student and Course

Relevant property for Student are StudentId and Budget

Relevant property for Course are CourseId and Price

Student and Course are entities that can exists on its own and have their own life cycle

Business requirements:

1) Student can book one course (CourseId is fk for Student table)

2) Student can book the course only if the user's budget is higher or equal to the course price.

3) Changes of course price doesn’t affect the students have already booked the course.

4) When the student book the course the his budget remains unchanged (maybe changes later at the end of the course)

5) Student budget can be modified setting a different amount but new amount have to be higher or equal to the price of the course the user booked.
Setting a lower amount should throw a runtime error.

What the way to model this simple case following domain driven design? Where to enforce the two busines rules (points 2 and 5)

Aucun commentaire:

Enregistrer un commentaire