This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Seperate classes or just one big class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Seperate classes or just one big class" Watch "Seperate classes or just one big class" New topic
Author

Seperate classes or just one big class

Hector Tenedero
Ranch Hand

Joined: Oct 13, 2008
Posts: 31
Hello and good day!

I would just like to ask if I should seperate CRUD operations into several classes or just make a one big class that would hold all methods?

To those who'll be able to provide help, I also kindly request you to please specify some pros and cons on the suggestions that you've given.



Thanks!
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30130
    
150

Hector,
Welcome to JavaRanch!

There are three common approaches:
1) One class per table - handling all CRUD operations
2) One class per type - one for queries, one for inserts etc.
3) One class per operation - one for each CRUD operation on each table

None of these are inherently better or worse. #3 is great if using a framework that takes care of connection management though.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Hector Tenedero
Ranch Hand

Joined: Oct 13, 2008
Posts: 31
Thanks Jeanne! It really does help to have a good DB Design below the JDBC code.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Seperate classes or just one big class
 
Similar Threads
calculate the amount values stored form recordstore in J2ME midlet
How to handle all these jars?
listener classes-small doubt
j2me and POJO
Handling of events question