Pass parameter to method or use instance member

T

tony

Hello!

I just wonder if you out there have any your suggestion about this matter.

I have a class in this class I have an ArrayList.
In one instance method in this class I fill this ArrayList with values that
have been reda from db.

Now is it possible to say something about what is general best for this
method.
There is some different possibilities.
1. Is it to pass the ArrayList to this method.
2. Is it to pass the ArrayList to this method and return the ArrayList.
3. Use the ArrayList without passing or returning any ArrayList because it
is an instance member.

//Tony
 
G

Guest

Tony,
The fact of whether the method is an instance method or static doesn't
really have much to do with the use case, unless you have shared / static
data that could cause thread collisions where multiple threads are attempting
to call the method simultaneously.

I see no point in passing an ArrayList as a parameter to a method just
because the method returns an ArrayList as its output result object. The
method should be perfectly capable of creating its own ArrayList, and
populating it with out you having to supply one.


Is there some other concern operating here that you haven't explained?

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top