M
M
mefcorvi2011-07-06 16:57:05
.NET
mefcorvi, 2011-07-06 16:57:05

Domain Services, SRPs and Divine Objects?

There is a certain ProjectService domain service, which contains a huge amount of business logic associated with the Project domain entity. The problem is that this object is now in fact a divine object, severely violating both the Single Responsibility Principle (SRP) and the Separation of Interface Principle (IRP), which makes testing very difficult. In addition, due to the large number of methods and a decent amount of code, it becomes difficult to understand what is happening inside.
The question is, what is the best way to refactor this service? In theory, you need to divide this service into many independent classes. For example, if a service has three methods for different ways of creating a project, then according to Fowler, they should become three independent classes, but what will these new classes be? Instruction Processors? What is the best way to instantiate them? Pass parameters in constructor? Should they be stateless?
How would you do it? It would also be interesting to know how to do it correctly in the context of CQRS?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question