Sorry if my thread is place in incorrect forum.

Hai All ...

Could anybody help me? i'm praticing how to build the n'tier application. I have read some book tell about this, like "Building Client/Server Applications With VB.NET" by Jeff Levinson, beth massi video tutorial "building simple n-tier applications", and other else.

In my practice, i create 3 projects to handle each layer progress. That are DAL (Data Access Layer), BLL(Business Logic Layer) and UIL (User Interface Layer).

My problem is i don't want to use web service like beth massi do, and i don't want to use remote object like Jeff L do. So i decide to create it by my rules. Here above something that i do.

In DAL Section, I put all datasource like Beth Massi do over here. I also create a manager class like massi do to handle datasource over here. Also in this class, i create the UML structure of this datasource.

'SatuanManager.vb
Option Strict On
Option Explicit On

Imports TradingStudio.BLL.Structures
Imports TradingStudio.BLL.Interfaces
Imports System.Configuration
Imports System.Data
Imports System.Data.SqlClient

Public Class SatuanManager

    'Inherits MarshalByRefObject

    Implements ISatuan

    Public Sub Delete_Record(ByVal intUID As Integer) Implements BLL.Interfaces.ISatuan.Delete_Record

    End Sub

    Public Function Loading_Data() As BLL.DataSet_Satuan Implements BLL.Interfaces.ISatuan.Loading_Data
        Dim ta As New DAL.DataSet_SatuanTableAdapters.UnitTableAdapter
        Dim Satuan As New BLL.DataSet_Satuan

        ta.FillByFlag(Satuan.Unit)

        Return Satuan
    End Function

    Public Function Loading_Record(ByVal intUID As Integer) As BLL.Structures.Structure_Satuan Implements BLL.Interfaces.ISatuan.Loading_Record

    End Function

    Public Sub Save_Record(ByVal StrucSatuan As BLL.Structures.Structure_Satuan, ByRef intUID As Integer) Implements BLL.Interfaces.ISatuan.Save_Record

    End Sub

#Region "Private Attributes"
    Private paUnitUID As Integer
    Private paUnitID As String
    Private paUnitName As String
    Private paUnitModerator As String
    Private paUnitFlag As Boolean
    Private paUnitModified As Date
#End Region

    Public ReadOnly Property UnitUID() As Integer
        Get
            Return paUnitUID
        End Get
    End Property

    Public ReadOnly Property UnitFlag() As Boolean
        Get
            Return paUnitFlag
        End Get
    End Property

    Public ReadOnly Property UnitModified() As Date
        Get
            Return paUnitModified
        End Get
    End Property

    Public Property UnitID() As String
        Get
            Return paUnitID
        End Get
        Set(ByVal value As String)
            paUnitID = value
        End Set
    End Property

    Public Property UnitName() As String
        Get
            Return paUnitName
        End Get
        Set(ByVal value As String)
            paUnitName = value
        End Set
    End Property

    Public Property UnitModerator() As String
        Get
            Return paUnitModerator
        End Get
        Set(ByVal value As String)
            paUnitModerator = value
        End Set
    End Property

End Class

In BLL Section, the dataset which i put in DAL Section auto generate over this section. I also create two class again in this section. There are Interfaces class and Structures class.

'Interfaces.vb
Option Strict On
Option Explicit On

Imports TradingStudio.BLL

Namespace Interfaces

    Public Interface ISatuan
        Function Loading_Data() As DataSet_Satuan
        Function Loading_Record(ByVal intUID As Integer) As Structures.Structure_Satuan
        Sub Save_Record(ByVal StrucSatuan As Structures.Structure_Satuan, ByRef intUID As Integer)
        Sub Delete_Record(ByVal intUID As Integer)
    End Interface

End Namespace
'Structures.vb
Option Strict On
Option Explicit On

Namespace Structures

    <Serializable()> Public Structure Structure_Satuan
        'Public Structure Structure_Satuan
        Public UnitUID As Integer
        Public UnitID As String
        Public UnitName As String
        Public Moderator As String 'Sama Dengan Operator
        Public Flag As Boolean
        Public Modified As Date 'bisa juga dengan menggunakan byte()
    End Structure

End Namespace

In BLL Section, I build user form over here. Over this user form i create a datagridview to show the dataset rows.

'UI_Form.vb
Imports TradingStudio.BLL
Imports TradingStudio.DAL

Public Class Satuan_Main

    Private Sub Satuan_Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim DataSatuan As New DAL.SatuanManager

        Me.DataGridView1.DataSource = DataSatuan.Loading_Data.Unit

        With Me.DataGridView1
            .Columns("UnitUID").Visible = False
            .Columns("Flag").Visible = False
            .Columns("Modified").Visible = False
            .ReadOnly = True
        End With

    End Sub
End Class

And Here above my complete source :
myN-Tier

am i build a correct way of n-tier applications? where should i place user interface presentation? where should i place that uml object?

thank's

Comments
First post and code tags - Excellent.

My answer may appear a little far from your question, but here how I look to it.

In every applications we all write these layers are exist, but they were all exist in one place. Suppose you create a form which include one textbox and save button, in the save button there is an insertion to the information written in the textbox after validation.

The good N-Tire is where you can reduce time and coding for your entire solution (not your single application). The "N" is Unknown number of layer that may exist to help build a good architecture design. where you can re-use what you have build in this application in another application even with another programming language.

I divide the project in 3 parts,
- Form Controls (Button, ListBox, etc...)
- Data handling (connecting, handling, data validating)
- Common Functions

In form design I mean subclassing of each form control using usercontrol and if necessary build an .ocx from it where I can use in other programming language. If I need to change the back color of textbox, I don't need to open each form and change the color of the textbox, I simply change it in one place in the usercontrol.

In data handling, I create a class for each database back-end I use, and I use this class whenever I am developing. Here is a sample

Public Class MySQL
    Public Function CreateMySQLConnectionADODB(ByVal Server, ByVal Database, ByVal UserName, ByVal Password) As ADODB.Connection
        Dim cnn As New ADODB.Connection
        cnn.ConnectionString = _
        "DRIVER={MySQL ODBC 3.51 Driver};" & _
        "SERVER=" & Server & ";" & _
        "DATABASE=" & Database & ";" & _
        "UID=" & UserName & ";" & _
        "PWD=" & Password
        CreateMySQLConnectionADODB = cnn
    End Function
    Public Function CreateMySQLConnectionRDO(ByVal Server, ByVal Database, ByVal UserName, ByVal Password) As RDO.rdoConnection
        Dim _cnnRDOMySQL As New RDO.rdoConnection
        Dim _qryRDOMySQL As New RDO.rdoQuery
        _cnnRDOMySQL.Connect = "uid=root;pwd=" & Password & ";server=" & Server & ";driver={MySQL ODBC 3.51 Driver}; database=" & Database & ";dsn=;"
        _cnnRDOMySQL.CursorDriver = RDO.CursorDriverConstants.rdUseOdbc
        _cnnRDOMySQL.EstablishConnection()
        Return _cnnRDOMySQL
    End Function
End Class

Common function is procedure and function that is used in the application which don't belong to data such as

Public Class MyHardware
    Sub GetCDROMInfo(ByVal __CDROM As String)
        Dim alldrives() As DriveInfo = DriveInfo.GetDrives
        Dim _FreeSpace = Format(alldrives(3).TotalFreeSpace / 1024 / 1024 / 1024, "#0.0")
    End Sub
End Class

The way I do this is.
- Convert the form control to .ocx
- Convert the Data class to .dll
- Convert the common function to .dll

I can re-use them from any place, any environment.

thank's for your reply samir. Now i get a little description about n-tier application architecture ...

This article has been dead for over six months. Start a new discussion instead.