最初有一个DAL对象,我的BO呼叫信息,然后传递给UI.然后我开始注意到UI中的代码减少,并且有Controller类.什么是体面的推荐.
我目前正在构建我的
Public Class OrderDAL Private _id Integer Private _order as Order Public Function GetOrder(id as Integer) as Order ...return Order End Function End Class
然后我有控制器类(最近实现了这种风格)
Public Class OrderController Private Shared _orderDAL as new OrderDAL Public Shared Function GetOrder(id) As Order Return _orderDAL.GetOrder(id) End Function End Class
然后在我的申请中
My app Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click msgbox(OrderController.GetOrder(12345).Customer.Name) End Sub End app
我最初发现使用共享类时,无论何时需要获取数据,我都不必继续创建DAL的新实例
Dim _orderDAL as New OrderDal _orderDAL.GetOrder(1234) .....
你有什么看法?
谢谢