Home  /  Questions  /  Question

50   50
May 08, 2011

Are these 'Good Design Principles' of the Factory Method pattern?


I am new to Design Patterns.  Looking at the example code in the Design Pattern Framework, my understanding of the Factory Method pattern is that it uses the following "good design principles":

  1) Favor composition over inheritance - private List<Page> _pages = new List<Page>();
  2) Programming to an interface - Document[] documents = new Document[2];
  3) Encapsulating changes - public abstract void CreatePages();
  4) Between 2 classes we have week relationship, i.e. loose coupling
  5) Using open/close principle - cannot change existing classes but we can add more variants, i.e. extensions

Are my conclusions correct? 
Are there additional good Design Principles in the Factory Method?


380   99.9
May 22, 2011
This may be too late but, yes all your undestandings are correct. However, #1 varies on case by case basis.