L
L
LoliDeveloper2021-08-18 18:12:03
Java
LoliDeveloper, 2021-08-18 18:12:03

Whose objects to use: server or client?

I glue it into one project: a module with an application and a module with a server. I want them to use the same classes and not have to constantly copy classes from module to module with the slightest change.
And here's the question. Let's say I have a User class on the server and have the same class on the client. I made the client dependent on the server, that is, I removed the User class from the client and imported this class from the server module. And now it became interesting: what if, on the contrary, it is necessary to make the server dependent on the client? After all, we are implementing features on the client, and server progers must adapt to the front and all that. Although if both modules are written by one person, then it may not matter, but it's still interesting what people think.

ps: Help with tags

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2021-08-18
@LoliDeveloper

It is possible to get the third module for the general classes.

O
Orkhan, 2021-08-19
Hasanly @azerphoenix

I made the client dependent on the server, that is, I removed the User class from the client and imported this class from the server module.

You can create a common module and throw your common classes there.
In general, I do it like this: I create several modules, one of which is persistence, where entities and repositories are located, the second module is common, which contains utility classes and service classes, as well as the web module (where controllers, mappers, corresponding actions and their handlers are stored, templates, etc.). Well, then, if necessary ... for example, the api module for rest. I also create a separate module for flyway and storing sql scripts. Of course, your structure may differ depending on your task.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question