Open nigelmoses32 opened 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
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
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
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
BaseDie.gd
).3. Encapsulation and Modularization
_variable_name
) or exported variables to control access. This prevents unintended changes to critical data.4. Scene Inheritance and Prefabs
5. Separation of Concerns
NetworkManager.gd
to manage connections, disconnections, and data synchronization.GameManager.gd
focused only on managing the gameplay.6. Use Design Patterns
SettingsManager
orAudioManager
). This ensures there's a single point of control for shared resources.7. Delegate Responsibilities Using Composition
Player
could have separate components for managing health, score, and network status.Scripts
to differentNodes
under a parent object to handle specific functionalities.8. Scripting and Naming Conventions
9. Version Control Best Practices
.tscn
), but complex scenes can still lead to conflicts. Keep scenes small and modular so that fewer team members need to modify the same scene at once.10. Refactor Code for Clarity and Reusability
BaseDie
example was one such refactor, but look for similar patterns in other parts of your code.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:PlayerManager.gd:
ScoreUI.gd:
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!