I am wondering about which design approach to take while passing data between methods. Let's say i have a class which retrieves 40 values(fields) from a DB and it needs to pass these values to another class. What is the best way to pass the data. 1. Having get methods for each value. 2. Passing an single dimensional Array with 40 elements. Each method has it's own advantages and disadvantages. I am just curious how everyone else is handling this. -Hemanth
Sean MacLean
author
Ranch Hand
Joined: Nov 07, 2000
Posts: 621
posted
0
I think the cleanest and most 'oo'-centric way would be to create a 'container' class that represents the the result object. Within this object you could have all your accessor methods. For example, say you're searching the DB for a book. When you find it, do this
Where the Book is a simple class with accessor methods. This is a very powerful approach and becomes even more so when you want to pass around collections of Books. Hope this helps! Sean [This message has been edited by Sean MacLean (edited November 09, 2000).]
Hemanth Presingu
Ranch Hand
Joined: Oct 01, 2000
Posts: 30
posted
0
Thanks for your reply. Your answer looks like a good solution for my requirement. -Hemanth