title: Design Patterns Recommendation for Filtering Option
body: <p>I am thinking to create a filter object which filters and delete everything like html tags from a context. But I want it to be independent which means the design pattern I can apply will help me to add more filters in the future without effecting the current codes. I thought Abstract Factory but it seems it ain't gonna work out the way I want. So maybe builder but it looks same. I don't know I am kinda confused, some one please recommend me a design pattern which can solve my problem but before that let me elaborate the problem a little bit.</p>
  
  <p>Lets say I have a class which has Description field or property what ever. And I need filters which remove the things I want from this Description property. So whenever I apply the filter I can add more filter in underlying tier. So instead of re-touching the Description field, I can easily add more filters and all the filters will run for Description field and delete whatever they are supposed to delete from the Description context.</p>
  
  <p>I hope I could describe my problem. I think some of you ran into the same situation before.</p>
  
  <p>Thanks in advance...</p>
  
  <p><strong>Edit :</strong> </p>
  
  <p>I actually want to create filters as types/classes instead of regular methods or whatever. Like :</p>
  
  <pre><code>class TextFilter : IFilter
  {
     private string something;
     public string Awesome {get;set;}
     public string FilterYo(string textFiltered)
     {
        // Do filtering
     }
  }
  
  class HtmlFilter : IFilter
  {
     private string something;
     private string iGotSomething;
     public string Awesome {get;set;}
     public string FilterYo(string textFiltered)
     {
        // Do filtering
     }
  }
  
  class Main
  {
     protected void Main(object sender, EventArgs e)
     { 
        InputClass input = new InputClass();
        string filtered = new StartFiltering().Filter(input.Description); // at this moment, my input class shouldn't know anything about filters or something. I don't know if it makes any sense but this is what in my mind.
     }
  }
  </code></pre>
  
  <p>At this point if I want to apply Abstract Factory which would be meaningless or Builder as well. Because I don't want a particular thing, I need all of them kinda.</p>
  
  <p>Thanks for your answers by the way.</p>
  
  <p><strong>Edit 2 - Possible Answer for Me</strong></p>
  
  <p>Okay lets think about strategy pattern with interfaces rather than delegates.</p>
  
  <pre><code>interface IFilter //Strategy interface
  {
     string Filter(string text);
  }
  
  class LinkFilter:IFilter  //Strategy concrete class
  {
     public string Filter(string text)
     {
       //filter link tags and return pure text;
     }
  }
  
  class PictureFilter:IFilter //Strategy concrete class
  {
     public string Filter(string text)
     {
       //filter links and return pure text;
     } 
  }
  
  class Context
  {
     private IFilter _filter;
     private string _text;
     public Context(IFilter filter,string text)
     {
        this._filter = filter;
        this._text = text;
     }
  
     public void UpdateFilter(IFilter filter)
     {
        this._filter = filter;
     }
  
     public string RunFilter()
     {
  
       this._text = _filter.Filter(this._text);
       return this._text;
     }
  }
  
  class MainProgram
  {
     static void Main()
     {
        MyObject obj = new MyObject();
        LinkFilter lfilter = new LinkFilter();
        PictureFilter pfilter = new PictureFilter();
        Context con = new Context(lfilter,obj.Description);
        string desc = con.RunFilter();
        con.UpdateFilter(pfilter);
        desc = con.RunFilter();
     }
  }
  </code></pre>