jorge07 / symfony-6-es-cqrs-boilerplate

Symfony 6 DDD ES CQRS backend boilerplate.
MIT License
1.07k stars 187 forks source link

Remove User Factory in favour of Specification pattern #99

Closed jorge07 closed 5 years ago

jorge07 commented 5 years ago

Fixes #96

coveralls commented 5 years ago

Pull Request Test Coverage Report for Build 303


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/Domain/Shared/Specification/AbstractSpecification.php 0 1 0.0%
src/Infrastructure/User/Specification/UniqueEmailSpecification.php 7 8 87.5%
<!-- Total: 16 18 88.89% -->
Totals Coverage Status
Change from base Build 296: -0.3%
Covered Lines: 509
Relevant Lines: 534

💛 - Coveralls
zerai commented 5 years ago

Hi, checking uniqueness requirement in the handler is better (aggregate stay pure) in my opinion.

I have some doubt (theoretical) about implementation, I think 'UniqueEmailSpecification' is a normal domain service (change name in CheckUniqueEmail) if we use term "specification" should adhere at "specification "specification pattern" only 1 interface "SpecificationInterface" and UniqueEmailSpecification and other future specification class inherit from this interface. changing contract/interface broke the composition/chaining capabilities of this pattern.

Suggestion1: change the name of service, avoid confusion of the term 'specification'

Suggestion2: don't change the name but change the code and adhere to the pattern

jorge07 commented 5 years ago

Hey @zerai thanks for your feedback.

Specification abstraction added 👍

jorge07 commented 5 years ago

I keep uniqueness logic in the domain because is a requirement of the domain itself and IMO business rules when deeper, better.