Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Write database logic seperately for every specific query?

 
Jonas Kazlauskas
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, so I have some methods where queries are being executed AND some logic is being applied to the resultSet. I was advised to move my database logic out of the methods to make it easier to read and to make it less cluttered with lots of user interface code. So my question is, do I have to write a specific method containing database logic for every single method (cause queries differ)? Is it a good practice? Or shall I make database logic code more general to be used all over my program? But I don't want it to be too complex to read again... Here is my code.
Method containing database logic:


Method with ALL the database logic already out:
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I prefer the later approach. It lets you have a package of classes that just do database logic rather than have it sprinkled throughout your program.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic