Skip to main content

Posts

Showing posts from October, 2012

VBA versus .NET

Composite Pattern

A implementation of the composite pattern similar to a class that would be used for constructing a binary search tree.  Better, more detailed implementations are known as red-black or AVL trees. Salient Characteristic(s) Reduces complexity by treating objects consistently, as opposed to having different methods and properties for each collection Any modification method of a collection would nbe the same as modifying the container Code namespace DesignPatterns {     /// <summary>     /// An example of composite that might be used in a binary tree     /// In this case, the tree node is composed of tree nodes     /// Any modification method of a node, would be the same as modifying the node itself     /// </summary>     public class TreeNode      {         private int _Value;         public int Value         {             get { return _Value; }             set { _Value = value; }         }         private TreeNode _Parent;         public TreeNode Pare

Bridge Pattern

A bare-bones, generic implementation of the bridge pattern, using inheritance, polymorphism, and abstraction.  Salient Characteristic(s) Decouple classes, allowing them to vary independently Useful when frequent changes are made to classes Code namespace DesignPatterns {     /// <summary>     /// The implementor: the abstract class, and concrete implementation of one side of the relation     /// </summary>      public interface IBridgeAbstraction     {         void Build();     }          abstract class BridgeAbstraction : IBridgeAbstraction     {         public abstract void Build();     }     class ConcreteBridge1 : BridgeAbstraction     {         public override void Build()         {         }     }     class ConcreteBridge2 : BridgeAbstraction     {         public override void Build()         {         }     }               /// <summary>     /// The abstract class, and concrete implementation of other side of the relat