Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I use passive view, a flavor of the <a href="http://msdn.microsoft.com/en-us/magazine/cc188690.aspx" rel="nofollow noreferrer">Model View Presenter</a> pattern, with any web forms like development (.NET) to increase testability/maintainability/etc</p> <p>For example, your code-behind file might look something like this</p> <pre><code>Partial Public Class _Default Inherits System.Web.UI.Page Implements IProductView Private presenter As ProductPresenter Protected Overrides Sub OnInit(ByVal e As System.EventArgs) MyBase.OnInit(e) presenter = New ProductPresenter(Me) End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load presenter.OnViewLoad() End Sub Private ReadOnly Property PageIsPostBack() As Boolean Implements IProductView.PageIsPostBack Get Return Page.IsPostBack End Get End Property Public Property Products() As System.Collections.Generic.List(Of Product) Implements Library.IProductView.Products Get Return DirectCast(gridProducts.DataSource(), List(Of Product)) End Get Set(ByVal value As System.Collections.Generic.List(Of Product)) gridProducts.DataSource = value gridProducts.DataBind() End Set End Property End Class </code></pre> <p>This code behind is acting as a very thin view with zero logic. This logic is instead pushed into a presenter class that can be unit tested.</p> <pre><code>Public Class ProductPresenter Private mView As IProductView Private mProductService As IProductService Public Sub New(ByVal View As IProductView) Me.New(View, New ProductService()) End Sub Public Sub New(ByVal View As IProductView, ByVal ProductService As IProductService) mView = View mProductService = ProductService End Sub Public Sub OnViewLoad() If mView.PageIsPostBack = False Then PopulateProductsList() End If End Sub Public Sub PopulateProductsList() Try Dim ProductList As List(Of Product) = mProductService.GetProducts() mView.Products = ProductList Catch ex As Exception Throw ex End Try End Sub End Class </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload