This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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
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).]
Joined: Oct 01, 2000
Thanks for your reply. Your answer looks like a good solution for my requirement. -Hemanth