php-ddd
php-ddd copied to clipboard
Should a Specification / Policy be injected?
As mentioned by @Skahrz here:
- http://softwareengineering.stackexchange.com/questions/330637/specification-pattern-or-entity-value-object-validation#comment-704807
injecting a Policy / Sepcification seems to be just fine e.g.:
- https://github.com/citerus/dddsample-core/blob/master/src/main/java/se/citerus/dddsample/domain/model/cargo/Delivery.java#L63
Maybe it also has the advantage of making an implicit concept explicit?
General difference:
- http://stackoverflow.com/questions/14185139/difference-between-specification-and-a-policy
Another example based on an example @VaughnVernon of injecting a Domain Service (e.g. Policy) directly answered by @GitteTitter and commented by @Elders:
- http://stackoverflow.com/questions/16995688/injecting-domain-service-into-the-aggregateroots-in-ddd