John-Popovici / duel-of-the-eights

Other
1 stars 0 forks source link

Thematic Issue - Coding Standard for OOP and effective collaboration #128

Open nigelmoses32 opened 2 days ago

nigelmoses32 commented 2 days ago

If it's not obvious, the following text is from ChatGPT:

Prompt: I would like to modify my existing code base for the game to make it more Object oriented and modular, so that working with other people is easier without merge conflicts. What practical principles/changes can be applied to the existing code in Godot?

Answer: To make your existing game codebase more object-oriented and modular for better collaboration and to minimize merge conflicts, here are some practical principles and changes you can apply:

1. Single Responsibility Principle (SRP)

2. Inheritance and Polymorphism

3. Encapsulation and Modularization

4. Scene Inheritance and Prefabs

5. Separation of Concerns

6. Use Design Patterns

7. Delegate Responsibilities Using Composition

8. Scripting and Naming Conventions

9. Version Control Best Practices

10. Refactor Code for Clarity and Reusability

Example of Consolidating Game Components

Consider a common structure like the Game Flow Management. You could break it down as:

Each of these scripts is modular, allowing different team members to work independently without stepping on each other's toes.

Signal Example for Decoupling

If PlayerManager needs to notify the UI about score changes:

This approach keeps the UI loosely coupled with the PlayerManager.

Summary

Implementing these principles will make the project more maintainable, flexible, and significantly reduce the risk of merge conflicts, enabling smooth collaboration among team members. Let me know if you'd like a more in-depth guide on any of these principles!

nigelmoses32 commented 2 days ago

Working on updating the existing codebase to reflect the above standards as soon as possible (with priority given to 4X03 cause we don't want to fail lol), but hopefully, this will help with us working together and being able to assign issues (features/bugs) to individual people without worry about merge conflicts

nigelmoses32 commented 2 days ago

Part of implementing code this way, I should be creating template scripts or blank methods in scripts for the rest of the team to implement specific functionality, which should make it easier to pick up a feature or bug, assign it to yourself and read where the code should be implemented and start working

nigelmoses32 commented 1 day ago

When creating and organizing scripts in the hierarchy, there is a principle I'm trying to follow which seems sound. The Parent node, which is either the scene node or the gameManager for example, has direct references to the components under it (Like scoreboard, dice container, UI, and so on) and handles initializing if needed. Then when running, the parent can call functions in the child to affect the state of the child, but the child will only use signals for any communication back to the parent, which the parent will be connected to and looking for. This way the child nodes handle specific functionality and can be tested independantly with out need a lot of additional infrastructure