Navigation


Milos Solution Platform (External Blog)

The Milos Solution Platform is .NET's premier platform for building business applications. This blog is meant for developers who use or evaluate Milos. This blog is used to share tidbits of information provided by the Milos developers at EPS. Many of the posts put the spotlight on new features. We generally recommend that all Milos users (developers) at least scan this blog to keep up with the Milos news.

Content Area Footer

Wednesday, April 16, 2008
Data Load Controllers

We have recently introduced a fully-automatic way of creating external data loading mechanisms. This is achieved by means of so-called "data load controllers". So what is the basic idea behind these? Well, I am glad you asked! :-)

Milos provides great ways to load data in all kinds of data edit forms, from Windows to the Web, in all kinds of variation. For instance, one can simply use the SetEntityType<>() method to automatically load an entity of a certain type in a window or a web form. It is also possible to override LoadContents() and LoadSecondary() data methods to load additional data, or load it in slightly different ways.

This makes for easy ways of loading data. However, in some scenarios, we want to go even further. (We will always continue to support this approach as it provides the basis for all operations, but we want to provide more options). There are a few scenarios we want to simplify. Here are those considerations:

  1. This approach generally relies on inheritance. That is OK in many scenarios, but in some scenarios (such as ASP.NET web forms or WPF/Silverlight XAML), there are scenarios where one just wants to use an object instance for data loading. For instance, one might want to put a data panel into a web form without explicitly subclassing it. Those scenarios are currently supported by means of an event model. That is not a bad approach, but it is slightly different from the inheritance model, and the written code is not IL-compatible, since method signatures are differently, and so forth.
  2. Different interfaces may have a need to load the same data. For instance, 10 different forms of a windows application may need to load certain lookup tables. Or, an ASP.NET web form may need to load the same exact data as the WinForms or WPF equivalent. Neither the inheritance, nor the event model allows for simple code reuse in these scenarios.
  3. It is very hard to unit test data loading for UIs if the code is embedded in, or attached to the user interface classes.

We now provide an additional abstract option: All the data loading (and data handling) code can be put in an abstract class. Here is an example of such a class:

public class NameEditLoader : DataLoadController
{
    public override void Configure()
    {
        this.SetEntityType<NameBusinessEntity>();
    }

    public override object LoadSecondaryData()
    {
        NameBusinessObject names = NameBusinessObject.NewInstance();
        DataSet dsNames = names.GetList();
        names.Dispose();
        return dsNames;
    }
}

If you are familiar with current Milos loading code, then you will recognize all of this, because the code is identical to code that would go into a Windows Forms class as well as other types of UI classes. The main difference is that this code now sits in an external class. This class can now be used in an interface class. For instance, it could be used in a Windows Form or a WPF window like so:

public MyWindow() // Constructor
{
    InitializeComponent();
    this.DataLoadControllers.Add(new NameEditLoader());
}

The same exact object can also be used on a web form:

protected void Page_Load(object sender, EventArgs e)
{
    this.dataEditPanel1.DataLoadControllers.Add(new NameEditLoader());
}

The same object could also be used in XAML, or in a mobile app, and so forth. Also, the object can now be used stand-alone in unit test scenarios, which is extremely important in test driven development (TDD) and other scenarios where unit tests are needed. (And most applications need unit tests these days).

So we think this is a cool change. It is completely optional and everything that was there before is still available. But going forward, this is clearly the recommended approach.

 

Posted @ 4:08 AM by Egger, Markus (markus@code-magazine.com) -
Comments (6)




Comments:

RE: Data Load Controllers
Wednesday, June 29, 2011 7:27 PM by vibram 5 fingers - cai297472630@126.com

Great job on the blog, it looks great. I am going to save it and will make sure to visit weekly


rs gold sell
Tuesday, September 13, 2011 10:46 PM by Runescape - http://rs2web.com/

Runescape Accounts has different skills in which players can level up and try to achieve the maximum level. As of right now, the max level for every skill is set to 99. Not only this, but you also have multiple combat skills that you can use to defeat certain battles with. These combat skills include strength, attack, defense, magic, and ranged attack.Runescape items is always updating its content trying to keep players very occupied and entertained.rs2web.com is one reliable website that sells rs gold sell at very cheap rate.


RE: Data Load Controllers
Saturday, September 24, 2011 1:41 AM by Android developers - suchismita.pnda1989@gmail.com

There are mainly three type of member function we used..private,public and protected..Public can access by outside class also.. From your Information I came to know about all these thing..


RE: Data Load Controllers
Tuesday, November 08, 2011 6:47 PM by iPhone 4S Ringtone Maker - plant2013@gmail.com

iPhone 4S Ringtone Maker is the fastest and easiest way to create custom ringtones for your iPhone.


RE: Data Load Controllers
Tuesday, November 29, 2011 2:54 AM by JR. Tresor Paris - galas262031416@yahoo.cn

Nice blog.I love reading your blog because it has very interesting topics.


RE: Data Load Controllers
Wednesday, December 13, 2017 12:07 PM by boomessays.com review - damonkorbin@hotmail.com

I have always wanted to know how these controllers really worked and I found the perfectly explained article here. This article is great and I would love to see some more great articles like this on other topics as well.




Post a Comment:

Comment Title (required)

Your Name (optional)

Your Email (optional)

Your Web Site (optional)

Your Comment (required)

 

 

 

 

 

 

 

Syndication RSS 2.0 RSS 2.0

All My Blogs:
My personal blogs:
Dev and Publishing Dev and Publishing
Travel and Internat. Living Travel and Internat. Living
Other blogs I contribute to:
Milos Blog (US) Milos Blog (US)
VFPConv. Dev Blog (US) VFPConv. Dev Blog (US)
VFPConv. Dev Blog (DE) VFPConv. Dev Blog (DE)

 

Blog Archives
All Blog Posts

2010
    November (1)
2009
    July (2)
    February (2)
    January (1)
2008
    December (1)
    October (3)
    June (1)
    April (3)
    February (1)
    January (1)
2007
    December (1)
    October (2)
    September (2)
    July (1)
    June (2)
    May (4)
    April (6)
    March (8)
    February (3)
    January (2)
2006
    December (2)
    November (2)

 

 

 

This Blog is powered by MilosTM Collaboration Components.