How do I know when a class is an assistant or a service?

I am using DDD architecture in my project and I need to create a class to generate a GUID for use in another class.

Is this class that my GUID generates is an infrastructure service or an infrastructure helper?

How do I know when a class is an assistant or a service?

+6
source share
2 answers

A service that can serve some clients, and often this is an SOA specific entity. The helper provides a set of methods that are usually pure functions .

From my point of view, if a class that provides GUID generation functionality stores or uses this GUID for further needs, this is the Service class, otherwise I would say that it is Helper , because it is simple to work on the principle of doing and forget / generate and forget.

Often, if you can make a static method a helper method, it does not depend on any state of the class and does not affect it either.

+4
source

Glad you found the answer, but you might want to rethink the question itself. What is a helper? In DDD or elsewhere there is no such pattern or stereotype. Take a look at this answer . [Something] An assistant is usually a sign of an SRP violation or just a bad name. For example, if your language / framework does not provide Guid generation ( unlikely ), you can create your own GuidGenerator class. The name should reflect responsibility.

+2
source

Source: https://habr.com/ru/post/898376/


All Articles