Click here to Skip to main content
15,884,298 members
Articles / Programming Languages / C#

Refactoring to Adaptive Object Modeling: Strategy Pattern

Rate me:
Please Sign up or sign in to vote.
3.38/5 (13 votes)
20 Jun 20058 min read 90.9K   166   36  
Strategy methodology maintains that the operations and business rules or code flow of a class should be held as a collection of properties, as opposed to single method calls, which can be changed at runtime.
/* *******************************************************
 * This code created and or modified by Chris Lasater
 * http://www.geocities.com/lasaterconsult
 * Please refer all questions or comments to chris.lasater@gmail.com
 * 
 * You can use this code however you like, but please, make sure you give me 
 * credit on any publishings you do from this code. 
 * 
 * No warrenty is implied for any code here.
 * 
 *  ******************************************************* 
 */

using System;

using Strategy.Operation;

namespace Strategy.Entity
{
	/// <summary>
	/// Summary description for EntityType.
	/// </summary>
	public abstract class EntityType
	{                    
		private string _typeName;
		private Type _type;
		private EntityAttributeCollection _attributes = new EntityAttributeCollection();
		private OperationsCollection _operations = new OperationsCollection();
	
		public EntityType(string name, Type type)
		{
			_typeName = name;			
			_type = type;	
		}   
				
		public string Name
		{
			get{return _typeName;}
			set{_typeName = value;}					
		}		
				
		public Type TypeOf
		{
			get{return _type;}
			set{_type = value;}					
		}
				
		public EntityAttributeCollection Attributes
		{
			get{return _attributes;}
			set{_attributes = value;}					
		}

		public OperationsCollection Operations
		{
			get{return _operations;}
			set{_operations = 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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
Christopher G. Lasater

I am also a published author, please check out my book:
ISBN: 1-59822-031-4
Title: Design Patterns
Author:Christopher G. Lasater
More from my web site
Amazon.com


Comments and Discussions