By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,995 Members | 1,192 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,995 IT Pros & Developers. It's quick & easy.

Pass parameter to method or use instance member

P: n/a
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
Jun 20 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"tony" wrote:
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

Jun 20 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.