Multiple Application Service Methods per Class

Sometimes it might be a good idea to group cohesive Application Services under the same class:

class UserService
{
// ...
public function signUp(SignUpUserRequest $request)
{
// ...
}

public function signIn(SignUpUserRequest $request)
{
// ...
}

public function logOut(LogOutUserRequest $request)
{
// ...
}
}

We don't recommend such an approach, as not all Application Services are 100 percent cohesive. Some Services will require different dependencies, and you'll end up with Application Services depending on things they don't need. Another issue is that this kind of class grows fast. As it violates the Single Responsibility Principle, there will be multiple reasons to change and maybe even break it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset