posted 22 years ago
Hi Guys,
This is a post to solidify my understanding and hopefully get some discussion comments back.
I have a class, call it MyClass, and I declare a reference variable to an object with class-scope:
Within some other method, methodA, in my class I call methodB, and within methodB I instantiate the reference to myObject. Then from within methodA I call methodC, and use the object (calling its methods etc):
So, is this the most object-oriented efficient way to do this?
Or is the most OO efficient way to do it like so:
Do not declare a reference with class-scope. Instead pass the reference of the object between the methods by copying the refernce into newly created objects:
What are the pros and cons of the two approaches?
Particularly the implications if I make changes to an object reference I have passed into another method etc.....
TIA
T