dinosaur-exploder icon indicating copy to clipboard operation
dinosaur-exploder copied to clipboard

[Feature]: re-orgonize the architecture of the project for cleaner code

Open jvondermarck opened this issue 8 months ago • 7 comments

👉 Please confirm the following

🤔 Is your proposal related to a problem?

Let's be honest, if you already have some IT skills, you can tell the code is messy, many many contributors worked on this project so in the end, some part of the code could be refactor, improved. Some files could be moved in specific folders to have a CLEAN ARCHITECTURE.

😍 Describe the solution you'd like

What I would like : refactor the code, fix the warnings, moves files into specific folders that collocates and so on.

[!CAUTION] BE CAREFUL : avoid breaking something in the code :) ahah

Anyway I am here to help, but let's take it seriously and make the life easier for people to contribute to the project.

[!TIP] Very important : look on internet how to make a clean architecture in Java / for games in JavaFX in general, how to name well the files, methods, folders, and variables. Avoid long methods (more than 50 lines), avoid long classes more than 100 / 150 lines of code. Break it down. It will make it easier to implement test in the future.

👍️ Describe alternatives you've considered

Look at this website for more information : https://refactoring.guru/fr/refactoring/what-is-refactoring

✍ Additional context

I will be very careful and might help on your PR if something could be improved, you're not alone if you have a question, let's make the code better and very easy to implement new features in the future.

jvondermarck avatar Apr 24 '25 17:04 jvondermarck

Now next step is to : refactor the DinosaurController, this class is so big, it does too many things, it's not good at all, a Controller shouldn't have game logic. The logic should be in some models classes. So if you could work on this it would be great !

And maybe create a folder interface for the interfaces to avoid having too much classes in a package like the components.

jvondermarck avatar Apr 25 '25 11:04 jvondermarck

@ursteiner You're still up for the job ? Thanks so much for making this project better ! Let's make a very very clean code.

Goal : to have many classes that does just one thing, that take care of one aspect of the game and avoid having a class that does so many things, we don't want this. So a big work is to be made for the DinosaurController

jvondermarck avatar Apr 25 '25 11:04 jvondermarck

There isn't a LevelComponent we should create one.

And create a class that handles the logic to set up the UI for the game information : so the level, coins, lives, and the score.

Look :

Image

This is a bit awful, anyway this class should be completely re-made again.

jvondermarck avatar Apr 25 '25 15:04 jvondermarck

I will fix this later this evening! 👌

ursteiner avatar Apr 25 '25 16:04 ursteiner

Hi @jvondermarck I didn't have time to proceed further, so I left it like it's now - still running fine. 😀 I think it's already in a much better shape!

ursteiner avatar Apr 25 '25 18:04 ursteiner

I managed to merge all the cool new features in my fork. It should now be ready for the PR.

ursteiner avatar Apr 26 '25 19:04 ursteiner

I re-open again the issue since there is still a lot of work to be made for the DinosaurController that should only contains few lines of code (now 400 approximately). :) The code is such a mess that now it is even hard to refactor it aha, but anyway we will succeed to make it very good and create many classes with only one responsibility to respect SOLID principles.

For example, initPhysics contains 100 lines, it has way too much logic and many many things.

jvondermarck avatar Apr 26 '25 22:04 jvondermarck

Hey! I’ve worked on refractoring the DinosaurController class and will be submitting a PR shortly. Hopefully this is still a topic of interest!

JustTOE avatar Sep 09 '25 17:09 JustTOE