How to build the correct way of n-tier apps without service and remoting?

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2007
Posts: 3
Reputation: witecloner is an unknown quantity at this point 
Solved Threads: 0
witecloner witecloner is offline Offline
Newbie Poster

How to build the correct way of n-tier apps without service and remoting?

 
1
  #1
Jul 4th, 2009
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.

  1. 'SatuanManager.vb
  2. Option Strict On
  3. Option Explicit On
  4.  
  5. Imports TradingStudio.BLL.Structures
  6. Imports TradingStudio.BLL.Interfaces
  7. Imports System.Configuration
  8. Imports System.Data
  9. Imports System.Data.SqlClient
  10.  
  11. Public Class SatuanManager
  12.  
  13. 'Inherits MarshalByRefObject
  14.  
  15. Implements ISatuan
  16.  
  17. Public Sub Delete_Record(ByVal intUID As Integer) Implements BLL.Interfaces.ISatuan.Delete_Record
  18.  
  19. End Sub
  20.  
  21. Public Function Loading_Data() As BLL.DataSet_Satuan Implements BLL.Interfaces.ISatuan.Loading_Data
  22. Dim ta As New DAL.DataSet_SatuanTableAdapters.UnitTableAdapter
  23. Dim Satuan As New BLL.DataSet_Satuan
  24.  
  25. ta.FillByFlag(Satuan.Unit)
  26.  
  27. Return Satuan
  28. End Function
  29.  
  30. Public Function Loading_Record(ByVal intUID As Integer) As BLL.Structures.Structure_Satuan Implements BLL.Interfaces.ISatuan.Loading_Record
  31.  
  32. End Function
  33.  
  34. Public Sub Save_Record(ByVal StrucSatuan As BLL.Structures.Structure_Satuan, ByRef intUID As Integer) Implements BLL.Interfaces.ISatuan.Save_Record
  35.  
  36. End Sub
  37.  
  38. #Region "Private Attributes"
  39. Private paUnitUID As Integer
  40. Private paUnitID As String
  41. Private paUnitName As String
  42. Private paUnitModerator As String
  43. Private paUnitFlag As Boolean
  44. Private paUnitModified As Date
  45. #End Region
  46.  
  47. Public ReadOnly Property UnitUID() As Integer
  48. Get
  49. Return paUnitUID
  50. End Get
  51. End Property
  52.  
  53. Public ReadOnly Property UnitFlag() As Boolean
  54. Get
  55. Return paUnitFlag
  56. End Get
  57. End Property
  58.  
  59. Public ReadOnly Property UnitModified() As Date
  60. Get
  61. Return paUnitModified
  62. End Get
  63. End Property
  64.  
  65. Public Property UnitID() As String
  66. Get
  67. Return paUnitID
  68. End Get
  69. Set(ByVal value As String)
  70. paUnitID = value
  71. End Set
  72. End Property
  73.  
  74. Public Property UnitName() As String
  75. Get
  76. Return paUnitName
  77. End Get
  78. Set(ByVal value As String)
  79. paUnitName = value
  80. End Set
  81. End Property
  82.  
  83. Public Property UnitModerator() As String
  84. Get
  85. Return paUnitModerator
  86. End Get
  87. Set(ByVal value As String)
  88. paUnitModerator = value
  89. End Set
  90. End Property
  91.  
  92. 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.

  1. 'Interfaces.vb
  2. Option Strict On
  3. Option Explicit On
  4.  
  5. Imports TradingStudio.BLL
  6.  
  7. Namespace Interfaces
  8.  
  9. Public Interface ISatuan
  10. Function Loading_Data() As DataSet_Satuan
  11. Function Loading_Record(ByVal intUID As Integer) As Structures.Structure_Satuan
  12. Sub Save_Record(ByVal StrucSatuan As Structures.Structure_Satuan, ByRef intUID As Integer)
  13. Sub Delete_Record(ByVal intUID As Integer)
  14. End Interface
  15.  
  16. End Namespace

  1. 'Structures.vb
  2. Option Strict On
  3. Option Explicit On
  4.  
  5. Namespace Structures
  6.  
  7. <Serializable()> Public Structure Structure_Satuan
  8. 'Public Structure Structure_Satuan
  9. Public UnitUID As Integer
  10. Public UnitID As String
  11. Public UnitName As String
  12. Public Moderator As String 'Sama Dengan Operator
  13. Public Flag As Boolean
  14. Public Modified As Date 'bisa juga dengan menggunakan byte()
  15. End Structure
  16.  
  17. End Namespace

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

  1. 'UI_Form.vb
  2. Imports TradingStudio.BLL
  3. Imports TradingStudio.DAL
  4.  
  5. Public Class Satuan_Main
  6.  
  7. Private Sub Satuan_Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  8.  
  9. Dim DataSatuan As New DAL.SatuanManager
  10.  
  11. Me.DataGridView1.DataSource = DataSatuan.Loading_Data.Unit
  12.  
  13. With Me.DataGridView1
  14. .Columns("UnitUID").Visible = False
  15. .Columns("Flag").Visible = False
  16. .Columns("Modified").Visible = False
  17. .ReadOnly = True
  18. End With
  19.  
  20. End Sub
  21. 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
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 147
Reputation: samir_ibrahim is on a distinguished road 
Solved Threads: 16
samir_ibrahim's Avatar
samir_ibrahim samir_ibrahim is offline Offline
Junior Poster

Re: How to build the correct way of n-tier apps without service and remoting?

 
0
  #2
Jul 4th, 2009
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

  1. Public Class MySQL
  2. Public Function CreateMySQLConnectionADODB(ByVal Server, ByVal Database, ByVal UserName, ByVal Password) As ADODB.Connection
  3. Dim cnn As New ADODB.Connection
  4. cnn.ConnectionString = _
  5. "DRIVER={MySQL ODBC 3.51 Driver};" & _
  6. "SERVER=" & Server & ";" & _
  7. "DATABASE=" & Database & ";" & _
  8. "UID=" & UserName & ";" & _
  9. "PWD=" & Password
  10. CreateMySQLConnectionADODB = cnn
  11. End Function
  12. Public Function CreateMySQLConnectionRDO(ByVal Server, ByVal Database, ByVal UserName, ByVal Password) As RDO.rdoConnection
  13. Dim _cnnRDOMySQL As New RDO.rdoConnection
  14. Dim _qryRDOMySQL As New RDO.rdoQuery
  15. _cnnRDOMySQL.Connect = "uid=root;pwd=" & Password & ";server=" & Server & ";driver={MySQL ODBC 3.51 Driver}; database=" & Database & ";dsn=;"
  16. _cnnRDOMySQL.CursorDriver = RDO.CursorDriverConstants.rdUseOdbc
  17. _cnnRDOMySQL.EstablishConnection()
  18. Return _cnnRDOMySQL
  19. End Function
  20. End Class

Common function is procedure and function that is used in the application which don't belong to data such as
  1. Public Class MyHardware
  2. Sub GetCDROMInfo(ByVal __CDROM As String)
  3. Dim alldrives() As DriveInfo = DriveInfo.GetDrives
  4. Dim _FreeSpace = Format(alldrives(3).TotalFreeSpace / 1024 / 1024 / 1024, "#0.0")
  5. End Sub
  6. 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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 3
Reputation: witecloner is an unknown quantity at this point 
Solved Threads: 0
witecloner witecloner is offline Offline
Newbie Poster

Re: How to build the correct way of n-tier apps without service and remoting?

 
0
  #3
Jul 4th, 2009
thank's for your reply samir. Now i get a little description about n-tier application architecture ...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC