dddshelf / last-wishes

Last Wishes is a PHP application written following Domain-Driven Design approach. It's one of the sample applications where you can check the concepts explained in the "Domain-Driven Design in PHP" book.
https://leanpub.com/ddd-in-php
660 stars 120 forks source link

Multiple Application Service Methods per Class #17

Open boedy opened 8 years ago

boedy commented 8 years ago

Hi, Thanks for your awesome book! I have a question:

On page 306 your say:

Using a dedicated class per Application Service makes the code more robust against external changes (Single Responsibility Principle). There are fewer reasons to change the class, as the Service does one and only one thing. The Application Service will be easier to test, seeing as it does less things. It’s easier to implement a common Application Service contract, making class decoration easier (check out the chapter on transactions in Repositories). This will also result in higher cohesion, as all dependencies are exclusively dedicated to a single use case. The execution method could have a more expressive name, like signUp. However, the execute Command pattern186 format standardizes a common contract across Application Services, thereby enabling easy decoration, which comes in handy for transactions.

How would you handle viewing " one wish" vs e.g. "All whishes"? Would this be:

  1. Two separate classes for the two use cases
  2. One class; Two methods
  3. One class; logic handled in the execute method based on parameter / request obj
  4. Another option?

Thanks.