I'm relatively new to python and oop, and i have a question around the design of my code for a hobby project.
I created a lot of variables in my main program. These variables are lists of objects (not configuration parameters and not constants). The objects in the lists are sprites.
I'm passing these variables around between objects, by calling methods and passing the variables around as arguments for a specific method. (pass-by-reference)
For example:
spritelist = [Sprite(...), Sprite(..)]
mycollisiondetector = CollisionDetector()
mycollisiondetector.check_collision(spritelist)
Then, in class CollisionDetector, spritelist is passed to "private" methods of the class. These private methods call other methods, and keep passing spritelist ... .
So, my question is just this: is there an alternative for endlessly passing variables around from one method to another ?
Copyright Notice:Content Author:「Rolf Schorpion」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/19424706/alternative-for-passing-references-around-in-python