Roll your own Web Part

Web Part was introduced in SharePoint Portal and will be adopted in ASP.NET 2.0. The whole Web Part infrastructure involves with the aspects in catalog, configuration, persistence and connection. I’m particularly interested in the connection feature.

To make a Web Part connectable to other Web Parts, it has to implement a set of interfaces. They are ICellProvider/ICellConsumer, IRowProvider/IRowConsumer, IListProvider/IListConsumer and IFilterProvider/IFilterConsumer. To coordinate the communication among the parts, each part also needs to override a few methods such as CommunicationConnect, CommunicationInit and CommunicationMain.

In the implementation, there are two base classes desgined to set up the framework. The BaseControl class is listed here.

	public class BaseControl : UserControl, IMessage	{
		public BaseControl() : base() {
		}
		public event ErrorMessageEventHandler ErrorMessage;
		public event MessageEventHandler Message;
		protected void OnMessage(object sender, MessageEventArgs e) {
			if (this.Message != null)
				this.Message(sender, e);
		}

		protected void OnErrorMessage(object sender, MessageEventArgs e) {
			if (this.ErrorMessage != null)
				this.ErrorMessage(sender, e);
		}

		protected override void Render(HtmlTextWriter writer) {
			base.Render(writer);
		}

		public virtual void CommunicationConnect() {}
		public virtual void CommunicationInit() {}
		public virtual void CommunicationMain() {}
	}

	public interface IRowProvider {
		event RowProviderInitEventHandler RowProviderInit;
		event RowReadyEventHandler RowReady;
	}
	public interface IRowConsumer
	{
		void RowProviderInit(object sender, RowProviderInitEventArgs e);
		void RowReady(object sender, RowReadyEventArgs e);
	}

The BasePage class defines the overall page layout and style, it also fires the CommunicationConnect/Init/Main methods on each connectable controls, plus other basic features that each page needs to share in common.

One needs to refactor and refactor the GUI design to get the best out of this architecture since suddenly many basic features of modern web user interface becomes reusable components that can be connected or composed into elaborate user interface to accompish rather sophisticated work.

New Order Entry GUI Design

Here’s a new GUI design I have come up for order entry management. In addition to a DOM price grid where one can click to generate a buy or sell bracket order with target and stop loss, a canvas is provided to manage orders.

The generated backet orders are represented in a canvas where all price levels are drawn in horizontal grids much like the ones in a chart. Each order such as entry, target and stop loss is reprresented by a circle or rectangle. These three or more circles or rectangles are linked with either dotted or solid lines to form a trade group. One can drag and drop or move the circles or rectangles around and they can anchor at any price grid lines. If one likes to scale in, more target circles or rectangles will be formed in the trade group. If an order is filled, it will be fixed at the filled price grid line vertically, but one can still move it horizontally.

As illustrated in the diagram, if ES is traded, the first trade has a Buy 1 ES (B1) with a target Sell 1 ES (T1) and stop loss Sell 1 ES (X1). The second trade has a Buy 2 ES (B2) and two targets Sell 1 (T1 and T1) and stop loss Sell 2 (X2). One can form multiple trade groups, each with different set of strategy that manages the targets and stop loss. The canvas provides a nearly free-form order entry management interface to any trading platform. In a way, it looks like a chess board!

Plugin Architecture

Today is the last day of my five-week architecture project at AspenTech. We have completed a very flexible and extensible architecture design with a working prototype for highly integrated desktop application framework and runtime infrastructure used in the process control and online optimiation applications.

At its core, it’s so-called Plugin concept that enables the runtime to be configured based on meta data. The runtime starts with an empty stack with some minimal bootstrap to discover and load the plugins. All the application functionalities are provided by the plugins. The plugins can work together based on the meta data instructions.

We have provided a set of default plugins to interpret the meta data, support a sophiscated GUI interface that utilizes the Model-View-Control design pattern. There’s a default Undo/Redo stack. All operations can be undone/redone. The object persistence is available as well.

The techniques used are XML seralization, object serialization, reflection, code generation, dynamic evaluation, etc. The prototype is implemented in C#. We have been using Extreme Programming and Pair Programming via Net Meeting all the time. The results are very good.

TabletPC SDK …

The TabeletPC project was over. I spent three weeks in Austin in Samsung’s Austin facility prototyping a solution to replace their current paper based auditing process in the fab.

We had to start the prototyping on XP without a TabletPC on hand. Within a week, we finally settled down the GUI design options that were best fit for our users’ taste and preferences. A lot of time we spent on was trying to explore the new features offered by the digital ink and pen. We chose two most promosing desgins with simple prototypes then presented them to the users. It turned out that they liked both:-) So we ended up a new desgin incorporating the features from both prototypes.

Soon we found out that TabletPC SDK had some undocumented limitations on how many Windows handles could be used. Our design called for a journal like interface where a user could just write down some short-hand codes, counts of violations and comments. The codes and counts are recognized and validated against a known list. Due to limited time, we had originally laid out as many rows of ink controls as we would need on the form, it turned out that SDK could not support it. We ended up using a template of controls and reused them.

Using factoids and well defined wordlists, the recognition accuracy is very high, but a traditional combobox still works very well.

The whole solution consists of a GUI frontend implemented in Windows Form and deployed via No Touch web deployment, a web site for reporting inplemented in ASP.NET and OWC, a server component implemented and deployed as .NET Remoting objects and a SQL Server 2000 as backend.

The security model is integrated Windows security all the way from user’s computer, the web server and the datbase server. It has offline feature to handle WI-FI connectivity issues when roaming in a fab lab. It’s written in C#.

Design Patterns and .NET

Microsoft has published a suite of design patterns using .NET. Not surprisingly, you can find striking similarities with the design patterns published by Sun Microsystems for the J2EE platform. Here’s the link for Patterns & Practices .

It’s definitely a good resource for architecting any solutions.

For discussion on patterns, visit this Patterns Community.

By the way, Mono project team has released Mono 0.24, which implements .NET on Linux.