• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Simple DataAccess Design Question

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply. Your answer looks like a good solution for my requirement.
-Hemanth
 
Right! We're on it! Let's get to work tiny ad!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic