Monday, September 20, 2004 - Posts

Virtual Cellar Application Architecture

This entry describes the initial application architecture for the Virtual Cellar application. The application utilizes a layered architecture broken down initially into three layers. Over time I will expand upon the layers to include a service layer and instrumentation layer. The class diagram below shows only a sampling of the classes involved in the Virtual Cellar system.

The UI Layer

The UI Layer will be based upon the User Interface Process Application Block (UIP), which is an implementation of the Model View Controller pattern. The UIP 2.0 GotDotNet workspace has a strong community, but little interaction with the team that developed it. I wrote a simple web app to demonstrate and learn how to use the UIP and make sure it does what I need for my my use.

The Business Layer

The business layer is made up of a Domain Model, in this case I am only showing the Producer and Wine classes for simplicity sake. The domain classes get there data from the Data Layer via the ProducerGateway and WineGateway classes which are implementations of the Table Data Gateway pattern. There are a couple of issues here that I will work on over time. According to Fowler  in his book Patterns of Enterprise Application Architecture, the Table Data Gateway pattern is not the best match for the Domain Model, and instead the Data Mapper pattern provides a more cohesive fit. For now this combination seems to work for me.

The Table Data Gateway classes provide methods for instantiating, updating and persisting domain objects.

The Data Layer

The Data Layer uses the Provider Model to decouple the persistence layer from a particular implementation. In this case Data Providers are sub classed from the abstract VirtualCellarDataProvider which provides a static Instance() method for maintaining only one instance of the provider. It also supplies abstract methods for getting the necessary Data Provider interface with the implementation being specified in the .config file. The DB specific classes (Access, Firebird & Sql) provide the implementations for the interface.

Lorengo.VirtualCellar Application Overview

If I wanted to retrieve a list of  producers currently in the data store, I would write some code like this, purely hypothetical for now.

VirtualCellarManager vcm = new VirtualCellarManager();
ProducerGateway pg = vcm.GetProducerGateway();
ArrayList producers = pg.FindAll();

// Display the producer name foreach( Producer p in producers) {
  System.Console.WriteLine( "{0}", p.Name );

  // Display each wine for the producer
  foreach( Wine w in p.Wines )
  {
    System.Console.WriteLine( "{0}", w.Name );
  }
}

So, the next step is to begin defining the methods in the gateway interface. But before I do that I'll need to understand how I'll be using the Domain Model, and to do that I can either come up with Use Cases (a la Rational) or User Stories via Agile Programming and TDD. Tomorrow, I'll discuss what I've come up with.

with 2 Comments