Click here to Skip to main content
15,886,791 members
Articles / Programming Languages / C#

Using the Chain Of Command Design Pattern Concepts to Perform Validation and Processing of Complex Data

Rate me:
Please Sign up or sign in to vote.
4.75/5 (9 votes)
3 Mar 2011CPOL7 min read 124.4K   861   49  
An article demonstrating the usage of Chain of Command Design Pattern concepts to perform validation and processing of complex data.

/***************************************************************************************
 *  Author: Curt C.
 *  Email : harpyeaglecp@aol.com
 *  
 *  This software is released under the Code Project Open License (CPOL)
 *  See official license description at: http://www.codeproject.com/info/cpol10.aspx
 *  
 * This software is provided AS-IS without any warranty of any kind.
 *  
 *  Modification History:
 *  08/10/2009  curtc    Creation of class for www.codeproject.com example.
 ***************************************************************************************/

namespace ChainOfCommandExample.Data
{
    /// <summary>
    /// An oversimplified class for containing the data for one bank account transaction.
    /// </summary>
    public class AccountTransactionData
    {

        #region Private_Field_Data
        // Account number for which the transaction is applied:
        private int accountNumber;

        // Amount of the transaction
        private double amount;

        // Transaction Type: 'W' for withdrawal, 'D' for deposit
        char transactionType;
        #endregion


        #region Properties

        /// <summary>
        /// Gets the transaction account number.
        /// </summary>
        /// <value>The account number.</value>
        public int AccountNumber { get { return accountNumber; } }

        /// <summary>
        /// Gets the transaction amount.
        /// </summary>
        /// <value>The amount.</value>
        public double Amount { get { return amount; } }

        /// <summary>
        /// Gets the type of the transaction ('W' for withdrawal, 'D' for deposit).
        /// </summary>
        /// <value>The type of the transaction.</value>
        public char TransactionType { get { return transactionType; } }

        #endregion

       
        /// <summary>
        /// Initializes a new instance of the <see cref="AccountTransactionData"/> class.
        /// </summary>
        /// <param name="accountNumber">The account number.</param>
        /// <param name="amount">The amount.</param>
        /// <param name="transactionType">Type of the transaction.</param>
        public AccountTransactionData(int accountNumber, double amount, char transactionType)
        {
            this.accountNumber = accountNumber;
            this.amount = amount;
            this.transactionType = transactionType;
        }
    }
}

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
Software Developer (Senior)
United States United States
Senior Software Developer with background history in developing software for both Unix and Windows based systems using a variety of languages and technologies, including: C#, C++, C, and Java.

Comments and Discussions