K
K
Kirill Tekord2017-09-09 17:54:31
Programming
Kirill Tekord, 2017-09-09 17:54:31

What is the best name for a class that implements a business functionality (sevris? team?)?

For example, there is a ClientCreator class that implements the logic of creating a new client in the system. This class internally creates User and Client records, saves them to the database and triggers events. This class takes all the necessary arguments to work through the constructor and has a public execute method that does all the work.
Work with the class goes according to the following scheme:
1. An instance is instantiated;
2. The instance is configured. For example, mark doNotSendEmailNotification = false and give a link to the password generator to generate passwords for new users;
3. As a mandatory parameter, this is the initial data of the form, on the basis of which everything will be calculated and created.
4. Call the execute() method. The method does not return anything, but if there are errors, an exception is thrown.
As I understand it, this class belongs to the service layer of the application. What is the name of such classes? ClientCreatorService? And there is some conceptual difference between such services that are configured at the time of instantiation and, obviously, can work with only 1 instance of the form (execute has worked and that’s it, if you want to process another form, create a new instance), and services that can execute in execute accept some parameters (created a service, and in a loop you call execute for the desired form)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
cheevauva, 2017-09-09
@tekord

What you described is a Team. The fundamental difference is visible from your own question, passing through the constructor, you can save the state - but at the same time postpone the execution of the command, when, as in the second case, you immediately passed and immediately did the job. Based on the first option, it is possible to implement a command bus without any troubles. In the second case, if different data is passed to the execute method, the command bus will be more difficult to implement, perhaps, but more difficult.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question