Click here to Skip to main content
11,933,213 members (62,283 online)
Click here to Skip to main content


25 bookmarked

Optimizing Performance with Denormalization, Observer Design Pattern and Asynchronous Technique

, 24 Aug 2009 CPOL
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 CustomerObserver : Observer
        private string _name;
        private OrderController _subject;

        // Constructor
        public CustomerObserver(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("'Payment Amount' for Customer who places order {0} has been updated successfully too.", _subject.OrderID);
                this.State = ObserverState.UPDATE_FAILED;

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

        // 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.


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


About the Author

Pham Dinh Truong
Technical Lead
Vietnam Vietnam
I have been working in ASP.NET for more than 7 years. I've also been working on Java and Windows-based apps for more than 4 years. My core competences include ASP.NET, Design Patterns, SubSonic, Ajax, Asynchronous and Multi-threading. I'm particularly interested in building smart software with great UI/UX and rich User Experience.

Recently, I'm interested on developing online advertisements. It's so complicated just like studying a new programming language!

Feel free to discuss with me at:

Visit my home:

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.151126.1 | Last Updated 24 Aug 2009
Article Copyright 2009 by Pham Dinh Truong
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid