Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question on Meanwhile on the command side of my architecture. #43

Open
FrankyCTY opened this issue Sep 27, 2024 · 1 comment
Open

Question on Meanwhile on the command side of my architecture. #43

FrankyCTY opened this issue Sep 27, 2024 · 1 comment

Comments

@FrankyCTY
Copy link

FrankyCTY commented Sep 27, 2024

Hi Steve.

After looking into the article https://blogs.cuttingedge.it/steven/posts/2011/meanwhile-on-the-command-side-of-my-architecture/

I see that the way we have this interface "ICommandHandler" a seam into our application to make use of decorator pattern and it is a form of aspect-oriented programming (AOP).

Many application does not have this design, and the production code classes (not sure how to call them) usually have specific interface that define the behavior specification, such as ICustomerService for CustomerService e.g. which constraints the behavior by having the specifications of the methods in the interface contract.

By having this seam, we need something like ICommandHandlerDecorator which separate the data from the behavior specification.

That means the generic ICommandHandler interface only constraint the data used, but the behavior is not.


I am thinking in that case if I want to swap the dependency for e.g. testing, will it make it easier to have human error as we could pass in the wrong implementation when complying to the data constraint?

Although in the test use case, it is something we will spot the human error immediately when we run the test, also each command handler effectively only has 1 method.

Thanks.

@FrankyCTY
Copy link
Author

FrankyCTY commented Sep 28, 2024

My understanding after reading the command and query articles.

Lots of issues you mentioned in the query side of my architecture around the violations of SRP, OCP, ISP all comes down to cohesion, specifically caused by the informational cohesion. And what actually solves the problem is of course understanding the context, the business/product needs and the capabilities your applications need to offer, and design for a functional cohesion application that leads to good coupling (and less).

With the pattern you mentioned, we essentially switching from horizontal sliced to veritical sliced application architecture I supposed.

So the scope of this pattern is not like a simple class level pattern but an application architecture pattern as it could be a application wide changes especially we are dealing with cross cutting concern.

Since the consumers code will need to couple (connect) with this new interface which can be a seam for decorator class that encapsulate the cross cutting concern behaviors.


By the way, I am enjoying your amazing dependency injection principles, practices, and patterns book, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant