I have a beginner question. I searched a lot for an answer, but could not find the exact answer, so maybe some of the more experienced developers can help me with this.
So, let's say you have the following situation in your code (this is a simplified version of the situation):
SomeObject a1 = new SomeObject(); a1 = someMethod(a1); public SomeObject someMethod(SomeObject a1) { a1.changeVariable(); return a1; }
I have now heard from several people saying that passing an object reference to a method and catching the return value is the wrong coding practice. Unfortunately, no one can explain to me exactly why this is a bad coding practice, and my search for the reason came up with nothing. Can anyone explain why this is bad practice? I canβt come up with a situation where something for this could go wrong.
Thank you in advance, you good people have already helped me with answers to other people countless times, this is the first time I really needed to ask a question :)
source share