CSC/ECE 517 Fall 2012/ch2b 2w60 ns: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
 
(43 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Factory Method=
=Factory Method=


==General Resources==
==Overview of the Pattern==
===Overview of the Pattern===


Factory method pattern is an [http://en.wikipedia.org/wiki/Object-oriented_programming Object Oriented Programming] concept in which objects can be created without specifying the class to which they belong.Factory method pattern implement the concept of using an object to generate other objects.<ref name="web">http://www.oodesign.com/factory-pattern.html<br></ref>Factory method is thus a  type of [http://en.wikipedia.org/wiki/Creational_pattern creational pattern].  An interface is defined for object creation. However the subclasses decide which class they want to instantiate. Factory methods thus abstract object instantiation from the client.<ref name="userpagesfactory">http://userpages.umbc.edu/~tarr/dp/lectures/Factory.pdf<br></ref>
Factory method pattern is an [http://en.wikipedia.org/wiki/Object-oriented_programming Object Oriented Programming] concept in which objects can be created without specifying the class to which they belong.Factory method pattern implement the concept of using an object to generate other objects.<ref name="web">http://www.oodesign.com/factory-pattern.html<br></ref>Factory method is thus a  type of [http://en.wikipedia.org/wiki/Creational_pattern creational pattern].  An interface is defined for object creation. However the subclasses decide which class they want to instantiate. Factory methods thus abstract object instantiation from the client.<ref name="userpagesfactory">http://userpages.umbc.edu/~tarr/dp/lectures/Factory.pdf<br></ref>


Creating an object often requires complex processes not appropriate to include within a composing object. The object's creation may lead to a significant duplication of code, may require information not accessible to the composing object, may not provide a sufficient level of abstraction, or may otherwise not be part of the composing object's concerns. The factory method design pattern handles these problems by defining a separate method for creating the objects, which subclasses can then override to specify the derived type of product that will be created.


Wikipedia<ref name="wikipedia">http://en.wikipedia.org/wiki/Factory_method_pattern</ref> and dofactory<ref name="dofactory">http://www.dofactory.com/Patterns/PatternFactory.aspx#UML</ref> provide good explanations of the Factory Method Pattern. dofactory<ref name="dofactory"/> is much more concise than Wikipedia<ref name="wikipedia"/>. It is a good resource for quickly viewing the definition and participants of the pattern. Wikipedia<ref name="wikipedia"/>, on the other hand, is much more detailed, it goes into the motivation for the pattern and discusses use of the patterns in several languages such as Java and C#  at a high level.
==Directory of Sites==


javapapers<ref name="javapapers">http://javapapers.com/design-patterns/factory-method-pattern/</ref> is a good page that gives a basic overview of the pattern through the presentation of a concrete example in java language. There are other Java resources and resources for other languages that are similar below.
===1.Factory Method Design Pattern(codeproject.com)===
  http://www.codeproject.com/Articles/184765/Factory-Method-Design-Pattern


===UML===
This article provides the motivation for using Factory method and explains the Factory method through an example which is very intuitive. It describes as to how if you are the middle man or an online book store and a customer is buying a book from an online store, you would want to choose a distributor to have the book shipped to the customer based on some predefined criteria , without  making the customer aware of these details  and explains how this can be done in a seamless way by using the Factory method. This example and implementation makes the concept of Factory method very clear and also illustrates the fact that the implementation details should be hidden from the clients (the customer placing the order for a book in this case). The article also walks through the examples by providing UML diagrams and explanations for the same. It also provides a link to read about other related patterns.
Understand the UML diagram for the Factory method pattern can help you understand the purpose of the Factory method pattern, the classes involved and how they interact with each other. UML is not programming language specific, so you should be able look at the UML diagram in any of the resources that have them on this page, regardless of what languages you know.


[[File:Factoryuml.JPG|650 px|thumb|right|UML Diagram for factory method pattern <ref name="userpagesfactory" />
'''Positives''': The example provided illustrates the idea and the structure of the Factory method better than most other sites as it is very simple to understand and organized well.
]]
In the [http://en.wikipedia.org/wiki/Unified_Modeling_Language UML diagram] on the right, Product is the interface for the type of object created by the factory method. The Product interface is implemented by ConcreteProduct. The factory method which returns an object of type Product, is declared in Creator. The factory method is overridden inside ConcreteCreator to return an instance of ConcreteProduct.


'''Negatives''': Does not include examples in different programming languages and the disadvantages/challenges faced while using Factory method are not covered.


===2.Article on Factory method===
  http://gsraj.tripod.com/design/creational/factory/factory.html
This article explains the motivation behind using the Factory method in brief but focuses more on the implementation details of it. There are real-life examples provided as applications. This link is a good learning tool if one wants a running example of the full implementation details of the Factory method. Most other links focus just on the concept without providing the code for the implementation details. That issue has been well addressed in this article.The article also summarizes the advantages and disadvantages of using the Factory method.


'''Positives''': Many real-life application examples along with full implementation. Pros and cons of the Factory method are summarized well.


'''Negatives''': Textual content can be overwhelming


===3. Factory Method (oodesign.com)===
  http://www.oodesign.com/factory-method-pattern.html


This article starts off by describing the Factory method by giving a real-life application example as a motivation.  It then shows us the UML structure of it and the corresponding implementation. What stands out in this article is detailed example towards the end of the article. It describes a “Documents Application” example which is targeted to frameworks in desktop applications. It describes at length as to how different documents will be required to be instantiated in a different way and how the application will be unaware of this. It then proposes to solve the problem with Factory method design pattern. And also illustrates the implementation. It also highlights the issues which one might come across while implementing the Factory method which is interesting. This article is beneficial because the example shows us how in some cases we require to postpone the object creation decision to the subclasses and how this is achieved through the Factory method.


'''Positives''': Good real-life application examples, advantages and disadvantages of Factory method pattern are well explained in a concise manner.  Well structured and easy to understand. Includes implementation examples of Factory method as well.


===4.Factory Method(sourcemaking.com)===
  http://sourcemaking.com/design_patterns/factory_method


A good and simple resource for learning how to use the Factory method pattern in Java can be found on the site SourceMaking, a site devoted to teaching IT concepts such as Design Patterns and UML to professional developers<ref name="sourcemaking"> http://sourcemaking.com/design_patterns/factrory_method/c%2523 </ref>. This resource includes a number of Java (and C#) examples meant to explain the usage of the pattern as well as textual explanations if needed.


'''Positives''':An advantage to using this resource is that it uses less text and more examples to show how the Factory method pattern can be used. It is also helpful that this site has multiple examples that can help increase understanding through reinforcement and multiple viewpoints (and languages).


'''Negatives''':All of the examples are general examples using the pattern as opposed to real life situations or scenarios.


===5. Factory method pattern (Wikipedia)===
 
  http://en.wikipedia.org/wiki/Template_method_pattern


This is a wiki article on Factory methods, this gives a good explanation of the “definition” of Factory methods and description of the situation in which Factory method would come handy. The article introduces the Factory method concepts and the applicability of the same.  It then specifies the Factory method UML diagram. It also specifies code examples in various programming languages.


'''Positives''': Good article for a brief introduction to the topic.


'''Negatives''' : The examples provided are not explained well and does not demonstrate the concept very clearly. The content is not very intuitive .


=== Code Example ===
===6. Factory Method Design Pattern(dofactory.com)===
This example has been taken from <ref name="sourcemakingfact"> http://sourcemaking.com/design_patterns/factory_method/</ref>
  http://www.dofactory.com/Patterns/PatternFactory.aspx


public interface ImageReader {
The article gives an overall summary of the Factory method. It explains the components involved and then gives an implementation of the Factory method in C#.
    public DecodedImage getDecodedImage();
}
public class GifReader implements ImageReader {
    public GifReader( InputStream in ) {
        // check that it's a gif, throw exception if it's not, then if it is decode it.
    }
public DecodedImage getDecodedImage() {
      return decodedImage;
    }
}
public class JpegReader implements ImageReader {
    //...
}
In the example above the ImageReader interface is defined. In this interface, a method getDecodedImage is defined that should return a decoded image. However this image may have been encoded in any format for example GIFF or JPEG. Therefore the functionality of actually decoding the image is implemented inside two classes GifReader and JpegReader . In this way, the responsibility of creating objects decoded in the appropriate format has been delegated to the subclass implementing the interface.


===Summary===
'''Positives''': There is a section called “Participants”, which explains the different components involved in a Factory method. Most other articles do not specify the components in the pattern.
For a general overview and UML diagrams of the Factory method design pattern, we recommend:
*[http://en.wikipedia.org/wiki/Factory_method_pattern Wikipedia]
*[http://www.dofactory.com/Patterns/PatternFactory.aspx#UML dofactory]
*[http://sourcemaking.com/design_patterns/factory_method sourcemaking]
*[http://javapapers.com/design-patterns/factory-method-pattern/ javapapers]
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]


'''Negatives''': Lacks content on the precise definition and advantages of using Factory method. Does not explain the situations in which Factory method can be used and what problems it addresses.




==Ruby==
===7.Using Factory Method Pattern in Java (javapapers.com)===
===Summary===
  http://javapapers.com/design-patterns/factory-method-pattern


==Java & C#==
javapapers<ref name="javapapers">http://javapapers.com/design-patterns/factory-method-pattern/</ref> is a good page that gives a basic overview of the pattern through the presentation of a concrete example in java language. There are other Java resources and resources for other languages that are similar below.This site uses a mix of textual explanations and examples to explain the pattern.  
There are a variety of resources available for learning how to use the Factory method pattern in Java and C#. We group these together as they are syntactically similar languages. One of the most popular references for learning about Design Patterns in Java is the book "Head First Design Patterns"<ref name="head_first"/>; in this book an in-depth explanation of the Decorator Pattern can be found. This is probably more popular because of how in-depth its explanation is of the design pattern, using diagrams and an ongoing coding example. It is also worth noting the the coding example used in this book (and a number of resources dedicated to the Decorator pattern) is a Coffee class where you wish to "decorate" your coffee with different additional ingredients. If you are really interested in learning the ins and outs of the Decorator pattern and do not mind a lengthy read, this is the best reference to use in regard to learning and understanding how to use this pattern.


If you are interested in learning about the Decorator pattern for Java and/or C# but do not have enough time or energy to read the chapter in the "Head First Design Patterns"<ref name="head_first"/> book, there are other resources that can be used to achieve an understanding but are less textual. Most of the resources that are not highly verbose use an over-arching example to explain the pattern. A good and simple resource for learning how to use the Decorator pattern in Java can be found on the site SourceMaking, a site devoted to teaching IT concepts such as Design Patterns and UML to professional developers<ref name="sourcemaking"> http://sourcemaking.com/design_patterns/decorator - 2012?</ref>. This resource includes a number of Java (and C#) examples meant to explain the usage of the pattern as well as textual explanations if needed. An advantage to using this resource is that it uses less text and more examples to show how the Decorator pattern can be used. It is also helpful that this site has multiple examples that can help increase understanding through reinforcement and multiple viewpoints (and languages). A disadvantage to using this site is that all of the examples are general examples using the pattern as opposed to real life situations or scenarios (like the Coffee example). If it is more useful for you to have a more in-depth walk through of a general example, then using the "Decorator Pattern by Example" page may be more helpful <ref name="dpexample"> http://www.agiledeveloper.com/articles/DecoratorByExample.pdf - ? </ref>
'''Positives''': it is relatively short and includes a real world example. It also provides the code in a way that would make it simple to attempt to run it yourself and see how it works.


Some sites use over-arching real life examples to explain the Decorator pattern and its usage. The most popular of these examples (in any language) is the Coffee class mentioned previously, however there are other examples based on real life scenarios and situations that can relay the same information. One that seems to be useful in conveying the idea behind the Decorator pattern is using the pattern to report sports statistics for a given team. One site uses the example of a developer hired to create software that reports Soccer sports statistics <ref name="soccer">http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ - 2012 </ref>. This site uses a mix of textual explanations and examples to explain the pattern. One advantage to using this site is that it is relatively short and includes a real world example. It also provides the code in a way that would make it simple to attempt to run it yourself and see how it works. A disadvantage for this resource is that it does not break down exactly how it got all of its code so it may be difficult to understand how to get going on your own using your own "problem".
'''Negatives''': it does not mention how to approach a "problem" or how to solve complex problem. This is useful to understand the basics for people who are new to design patterns.


Although most examples for this pattern focus on other usages, it is possible to use the Decorator pattern with GUIs (Graphical User Interfaces). A useful example for understanding this usage can be found on OODesign.com <ref name="gui">http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html - ?</ref>. This site uses code and UML diagrams to explain the usage of Decorator when implementing GUIs. There are small textual explanations in between code snippets but the bulk of the page is code. This site is useful because it offers code that can easily be tested and/or modified if needed to gain a better understanding. Another advantage is that there is not much that has to be read. A disadvantage is that if the code given is not similar to what you are trying to achieve it may be difficult to understand whether you need to be using the Decorator pattern for you particular GUI; outside sources may be needed for this understanding.
===8.Java- Factory Method(blog)===
  http://javarevisited.blogspot.com/2011/12/factory-design-pattern-java-example.html
The above blog starts with the defining Factory method mainly static Factory method.Then the article gives the specific scenarios where the factory methods is to be used.Code example of real world scenario is used to explain the factory method.


===Summary===
'''Positives''':Real world examples are taken for explaining the design pattern.
For Java and C# resources, we recommend:
 
*[https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf Head First Design Patterns]
'''Negatives''':UML example is not given.
*[http://sourcemaking.com/design_patterns/decorator SourceMaking]
 
*[http://blog.image0.com/c-2/design-patterns-series-the-decorator-pattern-with-a-real-world-soccer-example/ blog.image0]
===9.Head First Design Patterns (Text Book)===
*[http://www.oodesign.com/decorator-pattern-gui-example-java-sourcecode.html OODesign]
  https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf
 
One of the most popular references for learning about Design Patterns in Java is the book "Head First Design Patterns"<ref name="head_first"> https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf </ref>; in this book an in-depth explanation of the Factory method Pattern can be found. This is probably more popular because of how in-depth its explanation is of the design pattern, using diagrams and an ongoing coding example.
 
===10. Factory Method Pattern(Video Link)===
  http://www.youtube.com/watch?v=yDEmb5XYc_s&feature=related
 
This is a small video demonstrating the use of Factory method. This video helps us learn two important problems that we would encounter if we did not use Factory method, and then explains how the Factory method solves this problem. The two issues addressed in this video are, if we do not use the Factory design pattern it becomes imperative that the client knows all the implementation details and hence extensibility would be a problem in the future, the other problem it focuses on is maintainability of the code, as instantiating all potential classes with the “new” keyword can make code complex and difficult to maintain. The author demonstrates as to how these issues can be addressed using the Factory method.It then demonstrates the use of Factory method through a running example.
 
'''Positives''': Identifies the problems like code maintainability and application extendibility in the absence of Factory method and explains how these problems can be addressed by Factory method.
 
'''Negatives''': The UML diagram explained is not a generalized one. It is specific to the example of ‘adding invoice headers’ .
 
===11. JAVA- Factory Method Design Pattern (Video Link)===
 
    http://www.youtube.com/watch?v=cDF5tyiamww
 
This video starts off by explaining the UML of the factory method in detail, it explains how addition of new factories and products is easy if we follow the Factory method paradigm. The article then does an extensive comparison between the Abstract Design pattern using an example of a  ‘family of widget’ and the Factory method using a ‘combo-box’ example .It points out the differences between the 2 patterns and explains the Factory method pattern in detail with a running code example . The video then discusses some of the key ‘characteristics’ of the Factory method, and explains the meaning of each characteristic in detail with the code example as a reference.
 
'''Positives''':  Comparison between Abstract method and Factory method which is usually misunderstood is well explained. The other highlight of this video is the section on the characteristics of the Factory method, as this can help us identify potential situations in which Factory method can be used.
 
'''Negatives''': Video is a little slow paced and does not talk about the different real-life applications that the Factory method can be used in as it concentrates only on the ‘combo-box’ example throughout the video.
 
===12. Factory Method Design Pattern(Video Link)===
  http://www.youtube.com/watch?feature=endscreen&v=ub0DXaeV6hA&NR=1
 
This video starts off by explaining the ‘what the Factory method’ is , it then answers the questions as to ‘When to use it’. The video further explains the UML diagram of the Factory method. It then gives a demo of implementing the Factory pattern from scratch.
 
'''Positives''': Full implementation of Factory method from scratch using a Java editor and hence makes it very easy to follow the example.
 
'''Negatives''': Does not talk about the components involved in the Factory pattern .It also Does not compare with other design Patterns like Abstract method which are often confused.
 
 
==Comparison Table==
 
The below table provides the comparison between the various websites that have useful information regarding Factory Method Pattern. The websites are rated on certain parameters with the maximum rating being (****) and the minimum ( nil ). The numeric count of the link is the same as represented above.Few websites cover all the parameters
 
{| class="wikitable"
|-
! Characteristic !! Link 1 !! Link 2 !! Link 3 !! Link 4 !! Link 5 !! Link 6 !! Link 7 !! Link 8 !! Link 9 !! Link 10 !! Link 11 !! Link 12
|-
| Suitable examples used(code) || **** || **** || **** || **** || ** || ** || ** || ** || **** || *** || **** ||****
|-
| Different programming Languages used || ||  ||  || **** || **** || * ||  || ** || **** || * || ** || **
|-
| UML Diagram examples ||****||****||****||****||****||****||**|| ||****||**||****||****
|-
| Motivation to study the particular design pattern ||****  || **** ||****  ||****  || **** ||**  ||*  ||**  ||****  ||****  ||****  ||****
|-
| Overall structure and content ||**** || *** || **** || **** || ** || ** || ** || *** || **** || **** || **** || ****
|-
| Real World usages ||**  || **** || **** ||  ||***  || *|| * || **** || **** || * || ** || **
|-
| Advantages and Disadvantages of the pattern ||**  ||****  ||****  || ** || ** ||*  ||  ||**  || **** || ** || ** ||**
|}


==Directory==
==References==
==References==


<references />
<references />

Latest revision as of 20:07, 19 November 2012

Factory Method

Overview of the Pattern

Factory method pattern is an Object Oriented Programming concept in which objects can be created without specifying the class to which they belong.Factory method pattern implement the concept of using an object to generate other objects.<ref name="web">http://www.oodesign.com/factory-pattern.html
</ref>Factory method is thus a type of creational pattern. An interface is defined for object creation. However the subclasses decide which class they want to instantiate. Factory methods thus abstract object instantiation from the client.<ref name="userpagesfactory">http://userpages.umbc.edu/~tarr/dp/lectures/Factory.pdf
</ref>

Creating an object often requires complex processes not appropriate to include within a composing object. The object's creation may lead to a significant duplication of code, may require information not accessible to the composing object, may not provide a sufficient level of abstraction, or may otherwise not be part of the composing object's concerns. The factory method design pattern handles these problems by defining a separate method for creating the objects, which subclasses can then override to specify the derived type of product that will be created.

Directory of Sites

1.Factory Method Design Pattern(codeproject.com)

  http://www.codeproject.com/Articles/184765/Factory-Method-Design-Pattern

This article provides the motivation for using Factory method and explains the Factory method through an example which is very intuitive. It describes as to how if you are the middle man or an online book store and a customer is buying a book from an online store, you would want to choose a distributor to have the book shipped to the customer based on some predefined criteria , without making the customer aware of these details and explains how this can be done in a seamless way by using the Factory method. This example and implementation makes the concept of Factory method very clear and also illustrates the fact that the implementation details should be hidden from the clients (the customer placing the order for a book in this case). The article also walks through the examples by providing UML diagrams and explanations for the same. It also provides a link to read about other related patterns.

Positives: The example provided illustrates the idea and the structure of the Factory method better than most other sites as it is very simple to understand and organized well.

Negatives: Does not include examples in different programming languages and the disadvantages/challenges faced while using Factory method are not covered.

2.Article on Factory method

  http://gsraj.tripod.com/design/creational/factory/factory.html

This article explains the motivation behind using the Factory method in brief but focuses more on the implementation details of it. There are real-life examples provided as applications. This link is a good learning tool if one wants a running example of the full implementation details of the Factory method. Most other links focus just on the concept without providing the code for the implementation details. That issue has been well addressed in this article.The article also summarizes the advantages and disadvantages of using the Factory method.

Positives: Many real-life application examples along with full implementation. Pros and cons of the Factory method are summarized well.

Negatives: Textual content can be overwhelming

3. Factory Method (oodesign.com)

  http://www.oodesign.com/factory-method-pattern.html

This article starts off by describing the Factory method by giving a real-life application example as a motivation. It then shows us the UML structure of it and the corresponding implementation. What stands out in this article is detailed example towards the end of the article. It describes a “Documents Application” example which is targeted to frameworks in desktop applications. It describes at length as to how different documents will be required to be instantiated in a different way and how the application will be unaware of this. It then proposes to solve the problem with Factory method design pattern. And also illustrates the implementation. It also highlights the issues which one might come across while implementing the Factory method which is interesting. This article is beneficial because the example shows us how in some cases we require to postpone the object creation decision to the subclasses and how this is achieved through the Factory method.

Positives: Good real-life application examples, advantages and disadvantages of Factory method pattern are well explained in a concise manner. Well structured and easy to understand. Includes implementation examples of Factory method as well.

4.Factory Method(sourcemaking.com)

  http://sourcemaking.com/design_patterns/factory_method

A good and simple resource for learning how to use the Factory method pattern in Java can be found on the site SourceMaking, a site devoted to teaching IT concepts such as Design Patterns and UML to professional developers<ref name="sourcemaking"> http://sourcemaking.com/design_patterns/factrory_method/c%2523 </ref>. This resource includes a number of Java (and C#) examples meant to explain the usage of the pattern as well as textual explanations if needed.

Positives:An advantage to using this resource is that it uses less text and more examples to show how the Factory method pattern can be used. It is also helpful that this site has multiple examples that can help increase understanding through reinforcement and multiple viewpoints (and languages).

Negatives:All of the examples are general examples using the pattern as opposed to real life situations or scenarios.

5. Factory method pattern (Wikipedia)

  http://en.wikipedia.org/wiki/Template_method_pattern

This is a wiki article on Factory methods, this gives a good explanation of the “definition” of Factory methods and description of the situation in which Factory method would come handy. The article introduces the Factory method concepts and the applicability of the same. It then specifies the Factory method UML diagram. It also specifies code examples in various programming languages.

Positives: Good article for a brief introduction to the topic.

Negatives : The examples provided are not explained well and does not demonstrate the concept very clearly. The content is not very intuitive .

6. Factory Method Design Pattern(dofactory.com)

  http://www.dofactory.com/Patterns/PatternFactory.aspx 

The article gives an overall summary of the Factory method. It explains the components involved and then gives an implementation of the Factory method in C#.

Positives: There is a section called “Participants”, which explains the different components involved in a Factory method. Most other articles do not specify the components in the pattern.

Negatives: Lacks content on the precise definition and advantages of using Factory method. Does not explain the situations in which Factory method can be used and what problems it addresses.


7.Using Factory Method Pattern in Java (javapapers.com)

  http://javapapers.com/design-patterns/factory-method-pattern

javapapers<ref name="javapapers">http://javapapers.com/design-patterns/factory-method-pattern/</ref> is a good page that gives a basic overview of the pattern through the presentation of a concrete example in java language. There are other Java resources and resources for other languages that are similar below.This site uses a mix of textual explanations and examples to explain the pattern.

Positives: it is relatively short and includes a real world example. It also provides the code in a way that would make it simple to attempt to run it yourself and see how it works.

Negatives: it does not mention how to approach a "problem" or how to solve complex problem. This is useful to understand the basics for people who are new to design patterns.

8.Java- Factory Method(blog)

  http://javarevisited.blogspot.com/2011/12/factory-design-pattern-java-example.html

The above blog starts with the defining Factory method mainly static Factory method.Then the article gives the specific scenarios where the factory methods is to be used.Code example of real world scenario is used to explain the factory method.

Positives:Real world examples are taken for explaining the design pattern.

Negatives:UML example is not given.

9.Head First Design Patterns (Text Book)

  https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf

One of the most popular references for learning about Design Patterns in Java is the book "Head First Design Patterns"<ref name="head_first"> https://docs.google.com/viewer?url=http%3A%2F%2Foreilly.com%2Fcatalog%2Fhfdesignpat%2Fchapter%2Fch03.pdf </ref>; in this book an in-depth explanation of the Factory method Pattern can be found. This is probably more popular because of how in-depth its explanation is of the design pattern, using diagrams and an ongoing coding example.

10. Factory Method Pattern(Video Link)

  http://www.youtube.com/watch?v=yDEmb5XYc_s&feature=related
  

This is a small video demonstrating the use of Factory method. This video helps us learn two important problems that we would encounter if we did not use Factory method, and then explains how the Factory method solves this problem. The two issues addressed in this video are, if we do not use the Factory design pattern it becomes imperative that the client knows all the implementation details and hence extensibility would be a problem in the future, the other problem it focuses on is maintainability of the code, as instantiating all potential classes with the “new” keyword can make code complex and difficult to maintain. The author demonstrates as to how these issues can be addressed using the Factory method.It then demonstrates the use of Factory method through a running example.

Positives: Identifies the problems like code maintainability and application extendibility in the absence of Factory method and explains how these problems can be addressed by Factory method.

Negatives: The UML diagram explained is not a generalized one. It is specific to the example of ‘adding invoice headers’ .

11. JAVA- Factory Method Design Pattern (Video Link)

   http://www.youtube.com/watch?v=cDF5tyiamww 

This video starts off by explaining the UML of the factory method in detail, it explains how addition of new factories and products is easy if we follow the Factory method paradigm. The article then does an extensive comparison between the Abstract Design pattern using an example of a ‘family of widget’ and the Factory method using a ‘combo-box’ example .It points out the differences between the 2 patterns and explains the Factory method pattern in detail with a running code example . The video then discusses some of the key ‘characteristics’ of the Factory method, and explains the meaning of each characteristic in detail with the code example as a reference.

Positives: Comparison between Abstract method and Factory method which is usually misunderstood is well explained. The other highlight of this video is the section on the characteristics of the Factory method, as this can help us identify potential situations in which Factory method can be used.

Negatives: Video is a little slow paced and does not talk about the different real-life applications that the Factory method can be used in as it concentrates only on the ‘combo-box’ example throughout the video.

12. Factory Method Design Pattern(Video Link)

  http://www.youtube.com/watch?feature=endscreen&v=ub0DXaeV6hA&NR=1 

This video starts off by explaining the ‘what the Factory method’ is , it then answers the questions as to ‘When to use it’. The video further explains the UML diagram of the Factory method. It then gives a demo of implementing the Factory pattern from scratch.

Positives: Full implementation of Factory method from scratch using a Java editor and hence makes it very easy to follow the example.

Negatives: Does not talk about the components involved in the Factory pattern .It also Does not compare with other design Patterns like Abstract method which are often confused.


Comparison Table

The below table provides the comparison between the various websites that have useful information regarding Factory Method Pattern. The websites are rated on certain parameters with the maximum rating being (****) and the minimum ( nil ). The numeric count of the link is the same as represented above.Few websites cover all the parameters

Characteristic Link 1 Link 2 Link 3 Link 4 Link 5 Link 6 Link 7 Link 8 Link 9 Link 10 Link 11 Link 12
Suitable examples used(code) **** **** **** **** ** ** ** ** **** *** **** ****
Different programming Languages used **** **** * ** **** * ** **
UML Diagram examples **** **** **** **** **** **** ** **** ** **** ****
Motivation to study the particular design pattern **** **** **** **** **** ** * ** **** **** **** ****
Overall structure and content **** *** **** **** ** ** ** *** **** **** **** ****
Real World usages ** **** **** *** * * **** **** * ** **
Advantages and Disadvantages of the pattern ** **** **** ** ** * ** **** ** ** **

References

<references />