Results 1 to 5 of 5
  1. #1
    Maven0 is offline Member
    Join Date
    Jul 2010
    Posts
    2
    Rep Power
    0

    Exclamation Confusion about DAO in Three-Tier Architecture!

    Hello all!
    Dear Members my question is related to Software-engineering approach about DAO (Data Access Object) in three tier architecture.
    Am a student and as for the final project of my course I had to develop a three tier web based application..
    the approach I choose for my project was I divided my classes into three layers as required by the architecture including a DAO Control class.
    and my DAO class has only one function which takes query as in string format from Entity classes and then return the result Set of that query in return.

    ->* public ResultSet getConnected(String query, int qType) { ... }*

    but one of my supervisor said that architecture demands the DAO should be independent from any external interference and the way you are providing query from outside is violating that rule so either store all the queries inside DAO or inherit all the class from DAO.

    but I m still a bit confused about it that how it violates the rule and what is is ideal scenario in which DAO shld be used.

    please Help, suggest. :)
    Thankyou!

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,337
    Blog Entries
    7
    Rep Power
    20

    Default

    A DAO layer takes care of all database intrinsics and hides that fact from the outer layers. Your DAO demands that an outer layer knows about SQL queries and result sets. It might be quite general but that's not the way a DAO is defined. It should have methods such as getEmployee(String empID), getEmployees() etc. The DAO is designed with the business layer demands in mind, i.e. it has no use to implement all sorts of hypthetical methods that are not needed by the business layer. Of course, if it turns out handy, you can 'channel' all your database access functionality through that single method but that method should not be part of the DAO's public API.

    kind regards,

    Jos
    Last edited by JosAH; 07-24-2010 at 02:38 PM.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,798
    Rep Power
    19

    Default

    As Jos says, it's about hiding the db from the rest of the code. The code doesn't actually need to know where the data it uses is coming from, so should only have to deal with business objects...that would allow you to change the implementation of your DAO (even easier if you had it as an interface) so that it, for example, called a web service, or dealt with a file system instead.

  5. #5
    Maven0 is offline Member
    Join Date
    Jul 2010
    Posts
    2
    Rep Power
    0

    Default

    JosAH & Tolls .. thnx alot for ur replies :) U helped me alot in clearing my confusions.. i now know that DAO shld ve an independent existence.. thats y ive put all my quesries inside my connection method instead of passing them as an argument frm outside. thnku again. :)

Similar Threads

  1. Question about architecture
    By sdmente in forum Advanced Java
    Replies: 7
    Last Post: 07-28-2010, 01:07 PM
  2. 3 tier application and database problem.
    By mcajavaprogramer in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 07-19-2010, 11:07 AM
  3. three tier Desktop Application
    By newmember in forum AWT / Swing
    Replies: 0
    Last Post: 07-27-2008, 03:10 PM
  4. Architecture Rules 2.0.1
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 11-17-2007, 02:03 PM
  5. Architecture of Any IDE...
    By vikki_pu in forum Other IDEs
    Replies: 5
    Last Post: 10-30-2007, 01:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •