K
K
kezeze2019-09-24 04:45:43
C++ / C#
kezeze, 2019-09-24 04:45:43

How to properly design a multi-user application?

Hello.
There is some C# application on the server that processes the tasks of various users, processes them in parallel using multithreading. This application consists of a set of classes, for example, a class that receives a list of active users, a class that processes a user, a class that receives user tasks, performs a task, and formats the result.
So ...
When the application is running, it is necessary to remember information about the user that is being processed (for example, even for logging, they say such and such a task is performed by such and such a user). It turns out that all developed classes must contain a reference to the user?
Like... The UserReceiver class defines a set of users and for each user create an instance of the UserHandler(User) class, then in this handler the list of active tasks for the user is defined and an instance of the TaskHandler(Task, User) class is created... and so on and on ...
i.e. it turns out that everything in the program, whatever it does, must be specified by the user (store the reference as a field, pass it in the constructor, somewhere in the method), as in the example of the Task Handler, which processes the task, returns the result, and it seems like it doesn’t matter for what the task of the user, but still, at least for the same logging, it is necessary to transfer information about the user ... But the nesting of classes can be deeper, but it turns out that for everything you need to pull the user.
This is such a simplified example, I hope the question is clear. The bottom line is that whether this is correct, whether this is how it usually happens, or whether this is the wrong approach, there is some kind of fundamental mistake.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Other planet, 2019-09-24
@BadElectrician

As I understand it, we are talking about the need to create the correct application architecture. Next, you mention a set of classes designed to perform different tasks, but related to the fulfillment of the main goal of the entire application. Maybe someone will offer you something different, but I suggest that you consider each class as a microservice . What it is and how to work with a set of microservices is well described in Kristian Horsdal's book Microservices on the .NET Platform, and you can read or listen to the application architecture here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question