none
separating data access - Busines logic and UI RRS feed

  • Question

  • Hi friends,

    I have a question which I could not sort out. I checked the previous posts, I saw something relevant but not exactly what i need to know.

    I would like to create an  Logical N-Tier application which will include  DAL,  BLL  and  UI.

    I decided to use TypedDataset created by visual studio dataset designer as the Data access layer , but my question would still remain even if I used custom entity classes .

    Now I am going to build a Business Logic layer  to provide the comunication between UI and DAL

    Lets assume that I have created the BLL and I use the following code in my UI.

     

    Me.DataGridView1.DataSource = mBLL.GetObject

    that works very well, also insert and update works very well.  Most of the places I use databinding,

    But in some cases i want to use such a code block:

    For Each mRow In mTable.Rows
    'Bla bla bla
     for example: create new user controls and add to the main form..
    Next

    To do so I have to have referance to the DAL from the UI, like :

    Dim mTable As New DataAccessLayer.XX.ObjectDataTable

    Dim mRow As DataAccessLayer.XX.ObjectRow

    It would be the case even if I used custom entity classes.

    It is not advised to access to DAL from the UI. So what is the best way to get this work, Do I have to create the same objects in BLL as the DAL, maybe creating classes which inherits from DAL can help, but I don't know if it is a professional sollution?  

    For example In BLL Library I could create class Like this:

    Public Class ObjectTable
    Inherits
    DataAccessLayer.XX.ObjectDataTable
    End Class

    and then in my UI I use this code

    Dim mTable As New BLL.ObjectTable

    This code works perfectly and I don't have to access to the DAL from the UI. But I m not sure if it is the professional way. I am lost.. I could not figure it out.  Please help !!!! .. I need professional advices.

     

    by the way, plase forgive my poor English..

    greetings Ayhan

     

     

     

    Tuesday, December 19, 2006 1:14 PM

All replies

  • The best option is you create another project for Bussiness Entities, in this project you declare all the classes for represent your tables of your database and then you can reference and use this entities in all layers, you can consult abut that in this site : http://msdn.microsoft.com/practices/topics/arch/default.aspx?pull=/library/en-us/dnbda/html/boagag.asp

    I hope that can help you.

    Elmer Carías
    Independant Consultant
    El Salvador, Central America

    Tuesday, December 19, 2006 3:51 PM
  • Hi Elmer

    Thank you for your answer. I could use two different technic to create my data access layer, Typed Dataset or Custom Classes (Custom Entity Classes - Business entities).

    I choose the typed dataset because it is very simple to genrate and use. Since I have a very limited time and  the application will not need a to provide perfect serialization, the typed datasets are just enough for me. 

     

    Maybe my question was not clear.  I have my classes and data adapters created by dataset designer, these are just like custom entity classes, all the methods are ready for me.   I want to seperate my application to 3 tier. DAL, BLL and UI.

    And while I am doing that, I want to be able to use the datatables  on my UI without being have to make direct connection to the DAL. I want to do it via BLL.

     

     

    Tuesday, December 19, 2006 5:40 PM
  • You need make 4 projects like that:

    http://www.cariasyasociados.com/ArquitecturaDistribuidaWebGeneral.htm

    This diagram is for the architecture i use in my apps, if you speak or can read spanish, the site is in spanish(i dont even had time to do in english) , but view the diagram "Diagrama de Capa de Presentacion Web" and with links you can explore how i separate the layers and the interaction and references between them. Note: i use "PL" for Presentation Layer,  "BL" for Bussiness Layer, "DL" for Data Access Layer and "EL" for Bussiness Entity Layer.

    I hope this can help you,

    Atte. Elmer Carías
    Software Architect
    El Salvador, Central America
    Cel: (503) 7207-5871

     

    Tuesday, December 19, 2006 6:04 PM
  • :) Thanks Elmer

    I don't speak spanish, but I wanted to try to understand the diagram, unfortunatelly the link does not work.. Any way thanks for trying

    Tuesday, December 19, 2006 6:13 PM
  • give me your email, and i can send you the diagram.

    Atte. Elmer Carías
    Software Architect
    El Salvador, Central America

    Tuesday, December 19, 2006 6:23 PM
  • Hi,

    I think instead of datasets, the concept of value objects fit more in your case. There are lot of free tools available to generate even value objects with methods to access them.

    http://DotNetWithMe.blogspot.com
    vikas goyal

    Wednesday, December 20, 2006 11:10 AM
  • Thank you all..

    Wednesday, December 20, 2006 2:12 PM