In order to refactor some methods into smaller ones, I need pass by reference, since I can only have one return type. I could create a different return or parameter type whenever I need to do this, but then I’d end up with a bunch of bloated, seemingly unnecessary classes.
What is the best alternative here, besides redesigning the program, which can’t be done?
edit: some of it CAN be redesigned, and that’s what I am doing, but, for example, at one point it is finding the minimum and second minimum values in a huge collection and then manipulating them. I wanted to split that into 2 methods – one finds, another manipulates – but it seems highly unlikely I’ll be able to do this cleanly.
You could do something like create a generic class that could handle out values from a function.
Here is an example of how the class could be used to get an integer from a function.
It is probably not the most elegant overall solution, but it will keep you from having to write a ton of classes if you do not want to do a more involved refactor.