Use of the ApplicationLogic class

by alski 27. January 2005 00:08
Use of the ApplicationLogic class
At work, I have been developing an application layer that can be reused in both Web and WinForms.I implemented this by defining an abstract ApplicationLogic class which since the Company business is processing orders, contained the ability to create a set of orders and process them.I then sub-classed these into ShoppingCartApplicationLogic and ImportApplicationLogic, with the ImportApplication being split into AmazonApplicationLogic and LastMinuteApplicationLogic. At the importApplicationLogic level I added an abstract FileReader (which builds the order Collection) and subclassed CSVFileReader and FixedFileReader. (XML would be trivial from there.) Finally the concrete LastMinuteFileReader and AmazonFileReader, take the CSV/Fixed and adds MakeOrder, which knows how to deal with the data as it how now been columnised. Anyway back to the point.In my out of hours coding, I have been struggling how to deal with MVC for the multi-threaded application I am working on, and suddenly it hits me. If I add in an ApplicationLogic, which does the job of dealing with the collection classes and other data, then I can make it a Singleton (see GOF) and hey presto, no more problems with threads not being able to find their data.Sometimes I really like design.UpdateOnce you move to this design you will find that you have to put events on your AppLogic class, and as you initialise the GUI, you add a handler for a particular event.i.e.
class AppLogic
{
 event StatusChanged;
 protected/public OnStatusChanged()
 {...}
}
class AppForm : System.Windows.Forms.Form
{
 public AppForm()
 {
  // Required for Windows Form Designer support
  InitializeComponent();
  AppLogic.Instance.StatusChanged+= new EventHandler(this.UpdateStatus);
 }
 public void UpdateStatus
 {
  LabelStatus.Text = "Status Changed";
 }

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

RecentComments

Comment RSS