H.Property Map Pattern

  1. Summary

      1. This pattern is used to simplify and reduce inheritance relationships in between the classes

      2. It says that if Classes differ only in term of properties then use a Property bag (Key -Value Pair) also called property bag to hold varying properties.

      3. This pattern is based on the design guidelines called "Classes are all about behavior"

      4. Property Bags are also called Extended Properties.

  2. Overview

  1. When to Use it

      1. When you have two or more classes that differ only in properties not in behavior then use this pattern to merge then in a single one.

  1. Example

      1. Guitar class design in which basic properties and behavior are always same but feature number of wire, head color etc differ from instance to instance.

  1. Implementation

            1. class Guitar

              1. {

              2. /// Guitar Methods

              3. /// Features

              4. Dictionary<string, string> Features = new Dictionary<string, string>();

              5. }