aspose file tools*
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 Spring in Action this week in the Spring 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
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30762
    
156

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.
 
Don't get me started about those stupid light bulbs.
 
subject: Seperate classes or just one big class