Alt-Org / Altzone-Server

REST API
9 stars 1 forks source link

Change idea for removing the forwardRefs. #304

Closed PlayJeri closed 3 weeks ago

PlayJeri commented 4 weeks ago

I looked in to the architecture change we were discussing.

All the forward refs in the service classes were unnecessary. I had misunderstood the usage of the forward ref earlier and thats why it was in so many places.

Turns out we only needed it in item.module.ts for stock and clan modules and in room.module.ts for item module. The only circular dependency now is ClanModule -> StockModule -> ItemModule -> ClanModule. But all the services can be free of forwardRefs.

I published a branch change/architecture that has these changes now. The application seems to work normally and passes the same tests as the dev branch does.

So this might be a good first step towards the new architecture.

PlayJeri commented 4 weeks ago

I also tried out the new Player won a game event flow you defined in the drawio diagram. I got it working so it might be a good choice. It still relies on forwards refs and circular dependencies so we need to make some changes to the module / service hierarchy but if you want to see the rough idea I published the branch change/new-gameData-event-flow.

MikhailDeriabin commented 4 weeks ago

@PlayJeri

Ok. We can add this architecture all at once, it should not be long.

As I have said, if you have finished all tasks with leaderboard and player tasks, I can do all the required changes, if we pause updates to the code.

As I have wrote in Discord, it is about the way we think of the dependencies, not only forwardRef calls etc. For example the Item can not know about storage existence such as Stock.

So, can I start to make these changes?

PlayJeri commented 4 weeks ago

@MikhailDeriabin

You can start with the changes. 👍