Click here to Skip to main content
15,881,172 members
Articles / All Topics

Optimizing Performance with Denormalization, Observer Design Pattern and Asynchronous Technique

Rate me:
Please Sign up or sign in to vote.
4.67/5 (6 votes)
24 Aug 2009CPOL6 min read 33.6K   156   25  
Making use of Denormalization, Observer Design Pattern and Asynchronous technique can enhance performance for any system with massive database.
/// -----------------------------------------------------------------------------
/// Copyright (C) 2009. All rights reserved.
/// <summary>
/// Example with ObserverPattern to foster the low-coupling and synchronize data while using Denormalization to enhance performance
/// </summary>
/// <history>
///     Status    Date         By             Comments
///     ------------------------------------------------------------------------
///     Created   10 Aug 2009  Henry          Created
///     ------------------------------------------------------------------------
/// </history>
/// -----------------------------------------------------------------------------

using System;

namespace ObserverPattern_Test
{
  /// <summary>
  /// The 'ConcreteObserver' class
  /// </summary>
  class SalesPersonObserver : Observer
  {
    private string _name;
    private OrderController _subject;

    // Constructor
    public SalesPersonObserver(OrderController subject, string name)
    {
      this._subject = subject;
      this._name = name;
    }

    public override void Update()
    {
      //YOUR CODE GOES HERE: Send a request to database to update total field for Customer table
      bool updateResult = true;

      if (updateResult) //Updated successfully
      {
          this.State = ObserverState.UPDATE_SUCCESSFUL;

          Console.WriteLine("'Total Sold Amount' for SalesPerson who processed Order {0} has been updated successfully too.", _subject.OrderID);
          Console.WriteLine();
      }
      else
          this.State = ObserverState.UPDATE_FAILED;

      Console.WriteLine("Observer '{0}'s state is '{1}'", _name, this.State);
      Console.WriteLine();
    }

    // Gets or sets subject
    public OrderController Subject
    {
      get { return _subject; }
      set { _subject = value; }
    }

  }

}


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer Evizi
Vietnam Vietnam
I love working with Web-based workflow automation systems, ERP systems for SME, Data Visualization and Augmented Intelligence.

I have been working in ASP.NET for more than 12 years. I've also been working on Java and Windows-based apps for more than 5 years. My core competencies include ASP.NET (+net core), MVC, Restful API, Advance JavaScript, JQuery, Bootstrap, SubSonic, Dapper, Entity Framework, Lucne.net, ElasticSearch Ajax... I'm particularly interested in building smart apps with great UI/UX and high earned value.

I love to write elegant code. I am a type of pragmatic personality.

Recently, I've been interested in developing SPA apps using Angular with NodeJS backend. I also love to write the progressive web apps which could be the next big thing for the mobile web.

Feel free to discuss with me at: phamdinhtruong@gmail.com


Comments and Discussions