What is the general way for designing OOP templates (data access)

Initially, there was a DAL object that my BO called for information, and then passed to the user interface. Then I started to notice reduced code in the user interface and there were Controller classes. What a decent recommendation.

I am currently structuring my

Public Class OrderDAL

    Private _id Integer
    Private _order as Order

    Public Function GetOrder(id as Integer) as Order

        ...return Order

    End Function

End Class

then I have controller classes (recently implemented this style)

Public Class OrderController

    Private Shared _orderDAL as new OrderDAL

    Public Shared Function GetOrder(id) As Order

        Return _orderDAL.GetOrder(id)

    End Function

End Class

Then in my application

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

I initially discovered that with the generic class I didn't need to create a new DAL instance when I needed to receive data

Dim _orderDAL as New OrderDal

_orderDAL.GetOrder(1234)

.....

What do you take?

thanks

+5
source share
5 answers

, , , , " " "" . , "OrderControllers".

OrderControllers factory:

OrderControllerFactory.ConfiguredOrderController().GetOrder(42);

: "ConfiguredOrderController()"? GetOrder (int id), . OrderController.

public interface IOrderController
{
    Order GetOrder(int Id)
}

public class OrderController: IOrderController
{
    public Order GetOrder(int Id)
    {}
}

public class OrderControllerFactory()
{
    public IOrderController ConfiguredOrderController()
    {}
}

, , , , .

0

, , . , Psuedo, , .

, ? , . , , , , singelton ().

, , ORM. CRUM , .

My $.02, , .

0

VB, VB, :

, , - , GUI/presentation . GUI - ( , ) .

, , .

!

0

Good practice — especially when you get to the point where the Controller needs to do more than just delegate to the underlying DAL.

0
source

All Articles