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.