Situation: I have class parcel
, which has property parcelStatus
- which is actually already object of it's class.
Need: I have to set some business rules about statuses and status changes, like "parcel should have only these statuses (STORNO, NEW, SENT, ORDERED)" and second rule set, eg. "parcel with NEW status can go only into statuses STORNO and ORDERED"
Questions: we have these 2 rules, in which class to put which rule ? We are talking here about Rich domain layer, not about ORM or mappers...
1) both rule goes to parcel
class ?
2) both rule goes to parcelStatus
class ?
3) allowed statuses to parcelStatus
and allowed status changes to parcel
?
I'm trying to follow:
- reusability (I can change ruleset and reuse eg. parcelStatus object in abother scenario)
- proper attachement of object properties
Logically seems to me, that both rules should go to parcel
class, but in another hand, statusCode
looks to me like property of parcelStatus
and should not be exposed to parcel object.
How to properly define these rules, please ?
Aucun commentaire:
Enregistrer un commentaire