Zomis / Games

Many kinds of games, playable in both multiplayer or local play. Replays, spectator mode, and AIs.
https://games.zomis.net
MIT License
17 stars 5 forks source link

Reduce code-duplication and make sure no duplicated code is written #320

Open Zomis opened 1 year ago

Zomis commented 1 year ago

Somehow I can't help but get the feeling that some features are re-invented multiple times.

I think this is because of the different approaches the project has been through:

This in addition to everything related, such as:

More effort needs to be taken to remove old code. The question then being of course: Which approach is the right one?

Could maybe ArchUnit https://www.archunit.org/use-cases help out with structuring the project better to remove duplicates and make code easier to find?

Zomis commented 1 year ago

This is kinda like https://xkcd.com/927/ but within the same project.

Zomis commented 1 year ago

I had an idea to make all scope-interfaces inherit from some basic Scope marker interfaces:

All these three inherit from a common Scope interface.

This can also then be asserted using ArchUnit. So far I don't regret this approach.

ArchUnit proves to be very very useful, with rules like:

Zomis commented 1 year ago

A sign of code duplication: I have three different games using some kind of event/trigger-system (Coup, Dungeon Mayhem, and one more which is not yet finished). I have three different implementations of an event/trigger system to be used in games.

Zomis commented 1 year ago

Some known sources of duplicated code: