DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: 3Tier Question

  1. #1
    Join Date
    Oct 2006
    Posts
    3

    3Tier Question

    Hi. Suppose I have an app (named MyApp) organized in the following way:

    1. MyApp.WebUI : the user interface
    2. MyApp.BOL : my entities, eg: Person, Departament, etc
    3. MyApp.DAL : the data access layer

    MyApp.WebUI references MyApp.BOL
    MyApp.BOL references MyApp.DAL

    In this scenario, if I want, I can access the DAL from the UI, thus breaking the 3tier aspect ... is there a way to avoid it? eg, to not let the UI access the DAL directly?

  2. #2
    Join Date
    Oct 2006
    Posts
    4
    I think entities should be a seperate class. The business object layers should contain a class that access the data layer. What we usually do is create a BOL class that access several class in DAL. This BOL class is specific to a page that access it. Example if we have a user page. This page should access the UserBOL.cs.

  3. #3
    Join Date
    Aug 2006
    Posts
    6
    Hi.

    Its always better to have 3-tier architecture. You ca have UI layer, Business Objects layer (eg: employee, department, etc) and Data Access Layer (DAL).

    The business object layer consists of high level functions such as:

    Insert_Employee (ByVal EmpId As Integer, Byval EmpName As String) As Integer

    This function internally populates required sql insert query or command object with appropraite parameters based on this function parameters and calls lower level functions of DAL such as ExecuteNonQuery(ByVal SqlQuery As String) As Integer or
    ExecuteNonQuery(ByVal Cmd As SqlCommand) As Integer.

    In this way your code will be highly efficient and scalable. So each layer will be independent of each other. And and

    There is no harm in calling DAL functions such as ExecuteNonQuery or ExecuteReader directly from UI Layer.

    Overlapping of the layers usually occurs as in your case. But maxmimum try to use dal layer from business object layer as I have explained above to have more robust code and overlap layers less often to avoid future headaches.

    I hope its clear now.

  4. #4
    Join Date
    Mar 2004
    Posts
    78
    Hi,

    Following the MVC patter you have a model, view and controller. Obviously the view knows how to show the model and that is it.
    The controller is the one that receives the user requests and initiates the operations on the model, the selects the view and gives it the control so that it may show the model again.

    The model obviously contains the Entities, VOs and so forth and definately can use the DB layer.

    So far the 3tier architecture is not broken.

    The real question is what is the model for your UI? Is it the entities only or something that can serve the user requests using the data layer(DAO) and the entities ?

    The answer is that the model or the middle tier is not just bussiness objects that taka part of the envirounment you describe but a more complex or abstract objects that agregate the bussiness entites and their transformation - save, load, delete and etc.
    usually we saprate all of this in packages and put in the middle tier BOs only. The in the view tier we put this abstract, agregated models used by the view and the controller as the are use case specific(what functinality we give to the user). Still they are part of the middle tier.

    Sometimes we brake the 3 tier architecture by putting the access to the persitence layer(data layer) and entities in the controller and thus we bend the rules but still it is a bad practice.

    This is what I think!

Similar Threads

  1. Display one record at a time!
    By ASP learner in forum ASP.NET
    Replies: 5
    Last Post: 10-08-2002, 07:17 PM
  2. Question on asp.net user/server controls
    By Andy Stephens in forum ASP.NET
    Replies: 1
    Last Post: 09-06-2002, 05:29 PM
  3. question on best programming option
    By James in forum .NET
    Replies: 2
    Last Post: 03-28-2002, 08:14 AM
  4. VB,STORED PROC, COM, DTC QUESTION?
    By melvin ng in forum VB Classic
    Replies: 1
    Last Post: 11-10-2000, 04:46 AM
  5. Performance question
    By John in forum VB Classic
    Replies: 2
    Last Post: 04-05-2000, 09:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center