How to better organize code

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By FelicePollano

I’m developing a toy game that imitate Zuma: https://github.com/FelicePollano/Soma.
The code I initially wrote was entirely contained in a scene, then I realized it was so generic that I can use in more than one level, so I moved to a class in a script and have the level scenes deriving from that class. Is this a good practice in Godot as well ( I come from object oriented design, so I’m a little biased )
Another question: I realized I can be further more generic by extracting the code driving the balls along the path to have more than one path per level, so I will have a third class containing the ball class engine that will be instantiated and parametrized in the code of the single level. Is this a good approach in Godot?
Thanks in advance.

:bust_in_silhouette: Reply From: magicalogic

Gdscript can be viewed as object oriented so principles of object oriented programming apply here. It is even in the best practices guide. Generally, using inheritance to reduce code duplication is a good thing. Also giving each object its own script instead of having one script controlling everything is a good idea as it reduces code complexity. This is a good thing as it really helps with bug fixing and maintenance of your code.

This seams like the approach you are taking so I think it’s fine.