<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ssivaku4</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ssivaku4"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Ssivaku4"/>
	<updated>2026-08-20T10:50:13Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57_ss&amp;diff=71247</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57 ss</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57_ss&amp;diff=71247"/>
		<updated>2012-11-28T19:20:36Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: Created page with &amp;quot;= Abstract Factory: A directory of sites = The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers from a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
The following websites provide a good overview and general overall explanation of the Abstract Factory Pattern:&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Abstract_factory_pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/abstract-factory-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory&lt;br /&gt;
&lt;br /&gt;
http://www.developer.com/design/article.php/626001/Pattern-Summaries-Abstract-Factory-Pattern.htm&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 /* GUIFactory example */&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Button {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual void paint() = 0;&lt;br /&gt;
     virtual ~Button() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual Button* createButton() = 0;&lt;br /&gt;
     virtual ~GUIFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ~WinFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
          &lt;br /&gt;
     ~OSXFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class Application {&lt;br /&gt;
 public:&lt;br /&gt;
     Application(GUIFactory* factory) {&lt;br /&gt;
         Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
         button-&amp;gt;paint();&lt;br /&gt;
         delete button;&lt;br /&gt;
         delete factory;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
     int sys;&lt;br /&gt;
     std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
     std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
 &lt;br /&gt;
     if (sys == 0) {&lt;br /&gt;
         return new WinFactory();&lt;br /&gt;
     } else {&lt;br /&gt;
         return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     Application application(createOsSpecificFactory());&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in C++ can be found here:&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/cpp/1&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/cpp/2&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://r3dux.org/2011/07/an-example-abstract-factory-design-pattern-implementation-in-c/&lt;br /&gt;
&lt;br /&gt;
===C#===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* GUIFactory example -- */ &lt;br /&gt;
 &lt;br /&gt;
 using System;&lt;br /&gt;
 using System.Configuration;&lt;br /&gt;
 &lt;br /&gt;
 namespace AbstractFactory &lt;br /&gt;
 {&lt;br /&gt;
     public interface IButton &lt;br /&gt;
     {&lt;br /&gt;
         void Paint();&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public interface IGUIFactory &lt;br /&gt;
     {&lt;br /&gt;
         IButton CreateButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class OSXButton : IButton // Executes fourth if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinButton : IButton // Executes fourth if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class OSXFactory : IGUIFactory // Executes third if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new OSXButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinFactory : IGUIFactory // Executes third if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new WinButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class Application &lt;br /&gt;
     {&lt;br /&gt;
         public Application(IGUIFactory factory) &lt;br /&gt;
         {&lt;br /&gt;
             IButton button = factory.CreateButton();&lt;br /&gt;
             button.Paint();&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class ApplicationRunner &lt;br /&gt;
     {&lt;br /&gt;
         static IGUIFactory CreateOsSpecificFactory()  // Executes second&lt;br /&gt;
         {&lt;br /&gt;
             // Contents of App{{Not a typo|.}}Config associated with this C# project&lt;br /&gt;
             //&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
             //&amp;lt;configuration&amp;gt;&lt;br /&gt;
             //  &amp;lt;appSettings&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- Uncomment either Win or OSX OS_TYPE to test --&amp;gt;&lt;br /&gt;
             //    &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;Win&amp;quot; /&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;OSX&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
             //  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
             //&amp;lt;/configuration&amp;gt;&lt;br /&gt;
             string sysType = ConfigurationSettings.AppSettings[&amp;quot;OS_TYPE&amp;quot;];&lt;br /&gt;
             if (sysType == &amp;quot;Win&amp;quot;) &lt;br /&gt;
             {&lt;br /&gt;
                 return new WinFactory();&lt;br /&gt;
             } &lt;br /&gt;
             else &lt;br /&gt;
             {&lt;br /&gt;
                 return new OSXFactory();&lt;br /&gt;
             }&lt;br /&gt;
         } &lt;br /&gt;
 &lt;br /&gt;
         static void Main(string[] args) // Executes first&lt;br /&gt;
         {&lt;br /&gt;
             new Application(CreateOsSpecificFactory());&lt;br /&gt;
             Console.ReadLine();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in C# can be found in the following sites:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/19240/C-Abstract-Factory-Pattern&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/Patterns/PatternAbstract.aspx&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/c%2523&lt;br /&gt;
&lt;br /&gt;
=== Java ===&lt;br /&gt;
 /* GUIFactory example -- */&lt;br /&gt;
  &lt;br /&gt;
 interface Button {&lt;br /&gt;
     void paint();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 interface GUIFactory {&lt;br /&gt;
     Button createButton();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class Application {&lt;br /&gt;
     public Application(GUIFactory factory) {&lt;br /&gt;
         Button button = factory.createButton();&lt;br /&gt;
         button.paint();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 public class ApplicationRunner {&lt;br /&gt;
     public static void main(String[] args) {&lt;br /&gt;
         new Application(createOsSpecificFactory());&lt;br /&gt;
     }&lt;br /&gt;
  &lt;br /&gt;
     public static GUIFactory createOsSpecificFactory() {&lt;br /&gt;
         int sys = readFromConfigFile(&amp;quot;OS_TYPE&amp;quot;);&lt;br /&gt;
         if (sys == 0) return new WinFactory();&lt;br /&gt;
         else return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in Java can be found here:&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/java/2&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/java/1&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
http://java.dzone.com/articles/design-patterns-abstract-factory&lt;br /&gt;
&lt;br /&gt;
http://www.java2s.com/Code/Java/Design-Pattern/AbstractFactoryPatternExample.htm&lt;br /&gt;
&lt;br /&gt;
http://www.allapplabs.com/java_design_patterns/abstract_factory_pattern.htm&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*http://en.wikipedia.org/wiki/Abstract_factory_pattern&lt;br /&gt;
&lt;br /&gt;
*Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). [http://it-ebooks.info/book/252/ ''Head First Design Patterns'']&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc Gamma, Erich]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). [http://www.informit.com/articles/article.aspx?p=1398599 &amp;quot;Design Patterns: Abstract Factory&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.codeproject.com/script/Membership/View.aspx?mid=319264 Veeneman, David]] (2009-10-23). [http://www.codeproject.com/Articles/4079/Object-Design-for-the-Perplexed &amp;quot;Object Design for the Perplexed&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [http://www.oodesign.com/abstract-factory-pattern.html &amp;quot;Abstract Factory: Implementation&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/strategy-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Strategy_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Creational_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Behavioral_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Prototype_pattern&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
*Scott Walters (2004). [http://perldesignpatterns.com/?CompositePattern Perl Design Patterns Book]&lt;br /&gt;
&lt;br /&gt;
*Geary, David (13 Sep 2002). [http://www.javaworld.com/javaworld/jw-09-2002/jw-0913-designpatterns.html &amp;quot;A look at the Composite design pattern&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/bridge-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Bridge_pattern&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/bridge&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_(software_concept)&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_method_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/factory-method-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Builder_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/19240/C-Abstract-Factory-Pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.dofactory.com/Patterns/PatternAbstract.aspx&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/abstract-factory-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/abstract_factory/cpp/1&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/abstract_factory/cpp/2&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
*http://r3dux.org/2011/07/an-example-abstract-factory-design-pattern-implementation-in-c/&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012&amp;diff=71246</id>
		<title>CSC/ECE 517 Fall 2012</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012&amp;diff=71246"/>
		<updated>2012-11-28T19:19:26Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;*[[CSC/ECE_517_Fall_2012/Table_Of_Contents]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 n xx]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w1 rk]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w20 pp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w5 su]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w6 pp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w4 aj]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w7 am]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w8 aa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w9 av]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w10 pk]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w11 ap]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1a 1w12 mv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w14 gv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w17 ir]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w18 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w22 an]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w21 aa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w21 wi]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w31 sa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1a 1w16 br]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1a 1w23 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w24 nr]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w15 rt]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w3 pl]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w32 cm]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w5 dp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w37 ss]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w67 ks]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w27 ms]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w29 sa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w33 op]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w19 sa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w34 vd]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w35 sa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1 1w30 rp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w58 am]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w47 sk]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w69 mv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w44 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w45 is]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w53 kc]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w40 ar]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w39 sn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w54 go]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w56 ms]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w64 nn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w66 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w40 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w42 js]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w46 sm]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w71 gs]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w63 dv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w55 ms]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w57 mp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w52 an]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch1b 1w38 nm]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w60 ac]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 1w62 rb]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w29 st]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w3_sm]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w30 an]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w17 pt]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w31 up]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w9 ms]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w19 is]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w26 aj]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w5 dp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w16 dp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w8 vp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w18 as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w3 jm]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w23 sr]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w11_aa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w15 rr]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2a 2w33 pv]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w20_aa]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w14_bb]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w21_ap]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w13_sm]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w4_sa]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w25_nr]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w12_sv]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w7_ma]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w6_ar]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w32_mk]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2a_2w10_rc]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w70_sm]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w67_sk]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w40_sn]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w22_sk]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w-1w65_am]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w59_bc]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w60_ns]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b 2w47 am]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w69_as]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w39_ka]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2b_2w35_av]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w36_av]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w37_ms]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w43_iv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w53_iv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w63_sp]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b 2w68 sa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w49_ps]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w52_sj]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w28_dh]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch1b 2w41 dc]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2b_1w59_nm]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2b_1w61_ps]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2b_2w57_ss]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2b_2w42_aa]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2b_1w61_ns]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2b_2w51_aa]]&lt;br /&gt;
*[[CSC/ECE_517_Fall_2012/ch2b_2w45_pg]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_2w48_aa]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b_1w70_nl]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b 2w64 bg]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b 2w62 pv]]&lt;br /&gt;
*[[CSC/ECE 517 Fall 2012/ch2b 2w34 mr]]&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71155</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71155"/>
		<updated>2012-11-20T04:23:22Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers from a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
The following websites provide a good overview and general overall explanation of the Abstract Factory Pattern:&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Abstract_factory_pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/abstract-factory-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory&lt;br /&gt;
&lt;br /&gt;
http://www.developer.com/design/article.php/626001/Pattern-Summaries-Abstract-Factory-Pattern.htm&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 /* GUIFactory example */&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Button {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual void paint() = 0;&lt;br /&gt;
     virtual ~Button() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual Button* createButton() = 0;&lt;br /&gt;
     virtual ~GUIFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ~WinFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
          &lt;br /&gt;
     ~OSXFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class Application {&lt;br /&gt;
 public:&lt;br /&gt;
     Application(GUIFactory* factory) {&lt;br /&gt;
         Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
         button-&amp;gt;paint();&lt;br /&gt;
         delete button;&lt;br /&gt;
         delete factory;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
     int sys;&lt;br /&gt;
     std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
     std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
 &lt;br /&gt;
     if (sys == 0) {&lt;br /&gt;
         return new WinFactory();&lt;br /&gt;
     } else {&lt;br /&gt;
         return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     Application application(createOsSpecificFactory());&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in C++ can be found here:&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/cpp/1&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/cpp/2&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://r3dux.org/2011/07/an-example-abstract-factory-design-pattern-implementation-in-c/&lt;br /&gt;
&lt;br /&gt;
===C#===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* GUIFactory example -- */ &lt;br /&gt;
 &lt;br /&gt;
 using System;&lt;br /&gt;
 using System.Configuration;&lt;br /&gt;
 &lt;br /&gt;
 namespace AbstractFactory &lt;br /&gt;
 {&lt;br /&gt;
     public interface IButton &lt;br /&gt;
     {&lt;br /&gt;
         void Paint();&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public interface IGUIFactory &lt;br /&gt;
     {&lt;br /&gt;
         IButton CreateButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class OSXButton : IButton // Executes fourth if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinButton : IButton // Executes fourth if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class OSXFactory : IGUIFactory // Executes third if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new OSXButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinFactory : IGUIFactory // Executes third if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new WinButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class Application &lt;br /&gt;
     {&lt;br /&gt;
         public Application(IGUIFactory factory) &lt;br /&gt;
         {&lt;br /&gt;
             IButton button = factory.CreateButton();&lt;br /&gt;
             button.Paint();&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class ApplicationRunner &lt;br /&gt;
     {&lt;br /&gt;
         static IGUIFactory CreateOsSpecificFactory()  // Executes second&lt;br /&gt;
         {&lt;br /&gt;
             // Contents of App{{Not a typo|.}}Config associated with this C# project&lt;br /&gt;
             //&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
             //&amp;lt;configuration&amp;gt;&lt;br /&gt;
             //  &amp;lt;appSettings&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- Uncomment either Win or OSX OS_TYPE to test --&amp;gt;&lt;br /&gt;
             //    &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;Win&amp;quot; /&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;OSX&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
             //  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
             //&amp;lt;/configuration&amp;gt;&lt;br /&gt;
             string sysType = ConfigurationSettings.AppSettings[&amp;quot;OS_TYPE&amp;quot;];&lt;br /&gt;
             if (sysType == &amp;quot;Win&amp;quot;) &lt;br /&gt;
             {&lt;br /&gt;
                 return new WinFactory();&lt;br /&gt;
             } &lt;br /&gt;
             else &lt;br /&gt;
             {&lt;br /&gt;
                 return new OSXFactory();&lt;br /&gt;
             }&lt;br /&gt;
         } &lt;br /&gt;
 &lt;br /&gt;
         static void Main(string[] args) // Executes first&lt;br /&gt;
         {&lt;br /&gt;
             new Application(CreateOsSpecificFactory());&lt;br /&gt;
             Console.ReadLine();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in C# can be found in the following sites:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/19240/C-Abstract-Factory-Pattern&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/Patterns/PatternAbstract.aspx&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/c%2523&lt;br /&gt;
&lt;br /&gt;
=== Java ===&lt;br /&gt;
 /* GUIFactory example -- */&lt;br /&gt;
  &lt;br /&gt;
 interface Button {&lt;br /&gt;
     void paint();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 interface GUIFactory {&lt;br /&gt;
     Button createButton();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class Application {&lt;br /&gt;
     public Application(GUIFactory factory) {&lt;br /&gt;
         Button button = factory.createButton();&lt;br /&gt;
         button.paint();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 public class ApplicationRunner {&lt;br /&gt;
     public static void main(String[] args) {&lt;br /&gt;
         new Application(createOsSpecificFactory());&lt;br /&gt;
     }&lt;br /&gt;
  &lt;br /&gt;
     public static GUIFactory createOsSpecificFactory() {&lt;br /&gt;
         int sys = readFromConfigFile(&amp;quot;OS_TYPE&amp;quot;);&lt;br /&gt;
         if (sys == 0) return new WinFactory();&lt;br /&gt;
         else return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in Java can be found here:&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/java/2&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/java/1&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
http://java.dzone.com/articles/design-patterns-abstract-factory&lt;br /&gt;
&lt;br /&gt;
http://www.java2s.com/Code/Java/Design-Pattern/AbstractFactoryPatternExample.htm&lt;br /&gt;
&lt;br /&gt;
http://www.allapplabs.com/java_design_patterns/abstract_factory_pattern.htm&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*http://en.wikipedia.org/wiki/Abstract_factory_pattern&lt;br /&gt;
&lt;br /&gt;
*Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). [http://it-ebooks.info/book/252/ ''Head First Design Patterns'']&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc Gamma, Erich]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). [http://www.informit.com/articles/article.aspx?p=1398599 &amp;quot;Design Patterns: Abstract Factory&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.codeproject.com/script/Membership/View.aspx?mid=319264 Veeneman, David]] (2009-10-23). [http://www.codeproject.com/Articles/4079/Object-Design-for-the-Perplexed &amp;quot;Object Design for the Perplexed&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [http://www.oodesign.com/abstract-factory-pattern.html &amp;quot;Abstract Factory: Implementation&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/strategy-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Strategy_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Creational_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Behavioral_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Prototype_pattern&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
*Scott Walters (2004). [http://perldesignpatterns.com/?CompositePattern Perl Design Patterns Book]&lt;br /&gt;
&lt;br /&gt;
*Geary, David (13 Sep 2002). [http://www.javaworld.com/javaworld/jw-09-2002/jw-0913-designpatterns.html &amp;quot;A look at the Composite design pattern&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/bridge-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Bridge_pattern&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/bridge&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_(software_concept)&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_method_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/factory-method-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Builder_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/19240/C-Abstract-Factory-Pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.dofactory.com/Patterns/PatternAbstract.aspx&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/abstract-factory-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/abstract_factory/cpp/1&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/abstract_factory/cpp/2&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
*http://r3dux.org/2011/07/an-example-abstract-factory-design-pattern-implementation-in-c/&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71146</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71146"/>
		<updated>2012-11-20T04:15:52Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Abstract Factory: A directory of sites */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
The following websites provide a good overview and general overall explanation of the Abstract Factory Pattern:&lt;br /&gt;
&lt;br /&gt;
http://en.wikipedia.org/wiki/Abstract_factory_pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/abstract-factory-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory&lt;br /&gt;
&lt;br /&gt;
http://www.developer.com/design/article.php/626001/Pattern-Summaries-Abstract-Factory-Pattern.htm&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 /* GUIFactory example */&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Button {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual void paint() = 0;&lt;br /&gt;
     virtual ~Button() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual Button* createButton() = 0;&lt;br /&gt;
     virtual ~GUIFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ~WinFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
          &lt;br /&gt;
     ~OSXFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class Application {&lt;br /&gt;
 public:&lt;br /&gt;
     Application(GUIFactory* factory) {&lt;br /&gt;
         Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
         button-&amp;gt;paint();&lt;br /&gt;
         delete button;&lt;br /&gt;
         delete factory;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
     int sys;&lt;br /&gt;
     std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
     std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
 &lt;br /&gt;
     if (sys == 0) {&lt;br /&gt;
         return new WinFactory();&lt;br /&gt;
     } else {&lt;br /&gt;
         return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     Application application(createOsSpecificFactory());&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in C++ can be found here:&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/cpp/1&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/cpp/2&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://r3dux.org/2011/07/an-example-abstract-factory-design-pattern-implementation-in-c/&lt;br /&gt;
&lt;br /&gt;
===C#===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* GUIFactory example -- */ &lt;br /&gt;
 &lt;br /&gt;
 using System;&lt;br /&gt;
 using System.Configuration;&lt;br /&gt;
 &lt;br /&gt;
 namespace AbstractFactory &lt;br /&gt;
 {&lt;br /&gt;
     public interface IButton &lt;br /&gt;
     {&lt;br /&gt;
         void Paint();&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public interface IGUIFactory &lt;br /&gt;
     {&lt;br /&gt;
         IButton CreateButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class OSXButton : IButton // Executes fourth if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinButton : IButton // Executes fourth if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class OSXFactory : IGUIFactory // Executes third if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new OSXButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinFactory : IGUIFactory // Executes third if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new WinButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class Application &lt;br /&gt;
     {&lt;br /&gt;
         public Application(IGUIFactory factory) &lt;br /&gt;
         {&lt;br /&gt;
             IButton button = factory.CreateButton();&lt;br /&gt;
             button.Paint();&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class ApplicationRunner &lt;br /&gt;
     {&lt;br /&gt;
         static IGUIFactory CreateOsSpecificFactory()  // Executes second&lt;br /&gt;
         {&lt;br /&gt;
             // Contents of App{{Not a typo|.}}Config associated with this C# project&lt;br /&gt;
             //&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
             //&amp;lt;configuration&amp;gt;&lt;br /&gt;
             //  &amp;lt;appSettings&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- Uncomment either Win or OSX OS_TYPE to test --&amp;gt;&lt;br /&gt;
             //    &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;Win&amp;quot; /&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;OSX&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
             //  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
             //&amp;lt;/configuration&amp;gt;&lt;br /&gt;
             string sysType = ConfigurationSettings.AppSettings[&amp;quot;OS_TYPE&amp;quot;];&lt;br /&gt;
             if (sysType == &amp;quot;Win&amp;quot;) &lt;br /&gt;
             {&lt;br /&gt;
                 return new WinFactory();&lt;br /&gt;
             } &lt;br /&gt;
             else &lt;br /&gt;
             {&lt;br /&gt;
                 return new OSXFactory();&lt;br /&gt;
             }&lt;br /&gt;
         } &lt;br /&gt;
 &lt;br /&gt;
         static void Main(string[] args) // Executes first&lt;br /&gt;
         {&lt;br /&gt;
             new Application(CreateOsSpecificFactory());&lt;br /&gt;
             Console.ReadLine();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in C# can be found in the following sites:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/19240/C-Abstract-Factory-Pattern&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/Patterns/PatternAbstract.aspx&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/c%2523&lt;br /&gt;
&lt;br /&gt;
=== Java ===&lt;br /&gt;
 /* GUIFactory example -- */&lt;br /&gt;
  &lt;br /&gt;
 interface Button {&lt;br /&gt;
     void paint();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 interface GUIFactory {&lt;br /&gt;
     Button createButton();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class Application {&lt;br /&gt;
     public Application(GUIFactory factory) {&lt;br /&gt;
         Button button = factory.createButton();&lt;br /&gt;
         button.paint();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 public class ApplicationRunner {&lt;br /&gt;
     public static void main(String[] args) {&lt;br /&gt;
         new Application(createOsSpecificFactory());&lt;br /&gt;
     }&lt;br /&gt;
  &lt;br /&gt;
     public static GUIFactory createOsSpecificFactory() {&lt;br /&gt;
         int sys = readFromConfigFile(&amp;quot;OS_TYPE&amp;quot;);&lt;br /&gt;
         if (sys == 0) return new WinFactory();&lt;br /&gt;
         else return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in Java can be found here:&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/java/2&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/java/1&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
http://java.dzone.com/articles/design-patterns-abstract-factory&lt;br /&gt;
&lt;br /&gt;
http://www.java2s.com/Code/Java/Design-Pattern/AbstractFactoryPatternExample.htm&lt;br /&gt;
&lt;br /&gt;
http://www.allapplabs.com/java_design_patterns/abstract_factory_pattern.htm&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*http://en.wikipedia.org/wiki/Abstract_factory_pattern&lt;br /&gt;
&lt;br /&gt;
*Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). [http://it-ebooks.info/book/252/ ''Head First Design Patterns'']&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc Gamma, Erich]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). [http://www.informit.com/articles/article.aspx?p=1398599 &amp;quot;Design Patterns: Abstract Factory&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.codeproject.com/script/Membership/View.aspx?mid=319264 Veeneman, David]] (2009-10-23). [http://www.codeproject.com/Articles/4079/Object-Design-for-the-Perplexed &amp;quot;Object Design for the Perplexed&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [http://www.oodesign.com/abstract-factory-pattern.html &amp;quot;Abstract Factory: Implementation&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/strategy-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Strategy_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Creational_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Behavioral_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Prototype_pattern&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
*Scott Walters (2004). [http://perldesignpatterns.com/?CompositePattern Perl Design Patterns Book]&lt;br /&gt;
&lt;br /&gt;
*Geary, David (13 Sep 2002). [http://www.javaworld.com/javaworld/jw-09-2002/jw-0913-designpatterns.html &amp;quot;A look at the Composite design pattern&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/bridge-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Bridge_pattern&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/bridge&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_(software_concept)&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_method_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/factory-method-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Builder_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/19240/C-Abstract-Factory-Pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.dofactory.com/Patterns/PatternAbstract.aspx&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/abstract-factory-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/abstract_factory/cpp/1&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/abstract_factory/cpp/2&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
*http://r3dux.org/2011/07/an-example-abstract-factory-design-pattern-implementation-in-c/&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71141</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71141"/>
		<updated>2012-11-20T04:11:47Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Java */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 /* GUIFactory example */&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Button {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual void paint() = 0;&lt;br /&gt;
     virtual ~Button() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual Button* createButton() = 0;&lt;br /&gt;
     virtual ~GUIFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ~WinFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
          &lt;br /&gt;
     ~OSXFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class Application {&lt;br /&gt;
 public:&lt;br /&gt;
     Application(GUIFactory* factory) {&lt;br /&gt;
         Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
         button-&amp;gt;paint();&lt;br /&gt;
         delete button;&lt;br /&gt;
         delete factory;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
     int sys;&lt;br /&gt;
     std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
     std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
 &lt;br /&gt;
     if (sys == 0) {&lt;br /&gt;
         return new WinFactory();&lt;br /&gt;
     } else {&lt;br /&gt;
         return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     Application application(createOsSpecificFactory());&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in C++ can be found here:&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/cpp/1&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/cpp/2&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://r3dux.org/2011/07/an-example-abstract-factory-design-pattern-implementation-in-c/&lt;br /&gt;
&lt;br /&gt;
===C#===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* GUIFactory example -- */ &lt;br /&gt;
 &lt;br /&gt;
 using System;&lt;br /&gt;
 using System.Configuration;&lt;br /&gt;
 &lt;br /&gt;
 namespace AbstractFactory &lt;br /&gt;
 {&lt;br /&gt;
     public interface IButton &lt;br /&gt;
     {&lt;br /&gt;
         void Paint();&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public interface IGUIFactory &lt;br /&gt;
     {&lt;br /&gt;
         IButton CreateButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class OSXButton : IButton // Executes fourth if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinButton : IButton // Executes fourth if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class OSXFactory : IGUIFactory // Executes third if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new OSXButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinFactory : IGUIFactory // Executes third if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new WinButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class Application &lt;br /&gt;
     {&lt;br /&gt;
         public Application(IGUIFactory factory) &lt;br /&gt;
         {&lt;br /&gt;
             IButton button = factory.CreateButton();&lt;br /&gt;
             button.Paint();&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class ApplicationRunner &lt;br /&gt;
     {&lt;br /&gt;
         static IGUIFactory CreateOsSpecificFactory()  // Executes second&lt;br /&gt;
         {&lt;br /&gt;
             // Contents of App{{Not a typo|.}}Config associated with this C# project&lt;br /&gt;
             //&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
             //&amp;lt;configuration&amp;gt;&lt;br /&gt;
             //  &amp;lt;appSettings&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- Uncomment either Win or OSX OS_TYPE to test --&amp;gt;&lt;br /&gt;
             //    &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;Win&amp;quot; /&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;OSX&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
             //  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
             //&amp;lt;/configuration&amp;gt;&lt;br /&gt;
             string sysType = ConfigurationSettings.AppSettings[&amp;quot;OS_TYPE&amp;quot;];&lt;br /&gt;
             if (sysType == &amp;quot;Win&amp;quot;) &lt;br /&gt;
             {&lt;br /&gt;
                 return new WinFactory();&lt;br /&gt;
             } &lt;br /&gt;
             else &lt;br /&gt;
             {&lt;br /&gt;
                 return new OSXFactory();&lt;br /&gt;
             }&lt;br /&gt;
         } &lt;br /&gt;
 &lt;br /&gt;
         static void Main(string[] args) // Executes first&lt;br /&gt;
         {&lt;br /&gt;
             new Application(CreateOsSpecificFactory());&lt;br /&gt;
             Console.ReadLine();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in C# can be found in the following sites:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/19240/C-Abstract-Factory-Pattern&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/Patterns/PatternAbstract.aspx&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/c%2523&lt;br /&gt;
&lt;br /&gt;
=== Java ===&lt;br /&gt;
 /* GUIFactory example -- */&lt;br /&gt;
  &lt;br /&gt;
 interface Button {&lt;br /&gt;
     void paint();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 interface GUIFactory {&lt;br /&gt;
     Button createButton();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class Application {&lt;br /&gt;
     public Application(GUIFactory factory) {&lt;br /&gt;
         Button button = factory.createButton();&lt;br /&gt;
         button.paint();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 public class ApplicationRunner {&lt;br /&gt;
     public static void main(String[] args) {&lt;br /&gt;
         new Application(createOsSpecificFactory());&lt;br /&gt;
     }&lt;br /&gt;
  &lt;br /&gt;
     public static GUIFactory createOsSpecificFactory() {&lt;br /&gt;
         int sys = readFromConfigFile(&amp;quot;OS_TYPE&amp;quot;);&lt;br /&gt;
         if (sys == 0) return new WinFactory();&lt;br /&gt;
         else return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in Java can be found here:&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/java/2&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/java/1&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
http://java.dzone.com/articles/design-patterns-abstract-factory&lt;br /&gt;
&lt;br /&gt;
http://www.java2s.com/Code/Java/Design-Pattern/AbstractFactoryPatternExample.htm&lt;br /&gt;
&lt;br /&gt;
http://www.allapplabs.com/java_design_patterns/abstract_factory_pattern.htm&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*http://en.wikipedia.org/wiki/Abstract_factory_pattern&lt;br /&gt;
&lt;br /&gt;
*Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). [http://it-ebooks.info/book/252/ ''Head First Design Patterns'']&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc Gamma, Erich]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). [http://www.informit.com/articles/article.aspx?p=1398599 &amp;quot;Design Patterns: Abstract Factory&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.codeproject.com/script/Membership/View.aspx?mid=319264 Veeneman, David]] (2009-10-23). [http://www.codeproject.com/Articles/4079/Object-Design-for-the-Perplexed &amp;quot;Object Design for the Perplexed&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [http://www.oodesign.com/abstract-factory-pattern.html &amp;quot;Abstract Factory: Implementation&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/strategy-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Strategy_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Creational_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Behavioral_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Prototype_pattern&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
*Scott Walters (2004). [http://perldesignpatterns.com/?CompositePattern Perl Design Patterns Book]&lt;br /&gt;
&lt;br /&gt;
*Geary, David (13 Sep 2002). [http://www.javaworld.com/javaworld/jw-09-2002/jw-0913-designpatterns.html &amp;quot;A look at the Composite design pattern&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/bridge-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Bridge_pattern&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/bridge&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_(software_concept)&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_method_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/factory-method-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Builder_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/19240/C-Abstract-Factory-Pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.dofactory.com/Patterns/PatternAbstract.aspx&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/abstract-factory-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/abstract_factory/cpp/1&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/abstract_factory/cpp/2&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
*http://r3dux.org/2011/07/an-example-abstract-factory-design-pattern-implementation-in-c/&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71134</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71134"/>
		<updated>2012-11-20T04:05:41Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 /* GUIFactory example */&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Button {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual void paint() = 0;&lt;br /&gt;
     virtual ~Button() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual Button* createButton() = 0;&lt;br /&gt;
     virtual ~GUIFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ~WinFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
          &lt;br /&gt;
     ~OSXFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class Application {&lt;br /&gt;
 public:&lt;br /&gt;
     Application(GUIFactory* factory) {&lt;br /&gt;
         Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
         button-&amp;gt;paint();&lt;br /&gt;
         delete button;&lt;br /&gt;
         delete factory;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
     int sys;&lt;br /&gt;
     std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
     std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
 &lt;br /&gt;
     if (sys == 0) {&lt;br /&gt;
         return new WinFactory();&lt;br /&gt;
     } else {&lt;br /&gt;
         return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     Application application(createOsSpecificFactory());&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in C++ can be found here:&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/cpp/1&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/cpp/2&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://r3dux.org/2011/07/an-example-abstract-factory-design-pattern-implementation-in-c/&lt;br /&gt;
&lt;br /&gt;
===C#===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* GUIFactory example -- */ &lt;br /&gt;
 &lt;br /&gt;
 using System;&lt;br /&gt;
 using System.Configuration;&lt;br /&gt;
 &lt;br /&gt;
 namespace AbstractFactory &lt;br /&gt;
 {&lt;br /&gt;
     public interface IButton &lt;br /&gt;
     {&lt;br /&gt;
         void Paint();&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public interface IGUIFactory &lt;br /&gt;
     {&lt;br /&gt;
         IButton CreateButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class OSXButton : IButton // Executes fourth if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinButton : IButton // Executes fourth if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class OSXFactory : IGUIFactory // Executes third if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new OSXButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinFactory : IGUIFactory // Executes third if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new WinButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class Application &lt;br /&gt;
     {&lt;br /&gt;
         public Application(IGUIFactory factory) &lt;br /&gt;
         {&lt;br /&gt;
             IButton button = factory.CreateButton();&lt;br /&gt;
             button.Paint();&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class ApplicationRunner &lt;br /&gt;
     {&lt;br /&gt;
         static IGUIFactory CreateOsSpecificFactory()  // Executes second&lt;br /&gt;
         {&lt;br /&gt;
             // Contents of App{{Not a typo|.}}Config associated with this C# project&lt;br /&gt;
             //&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
             //&amp;lt;configuration&amp;gt;&lt;br /&gt;
             //  &amp;lt;appSettings&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- Uncomment either Win or OSX OS_TYPE to test --&amp;gt;&lt;br /&gt;
             //    &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;Win&amp;quot; /&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;OSX&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
             //  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
             //&amp;lt;/configuration&amp;gt;&lt;br /&gt;
             string sysType = ConfigurationSettings.AppSettings[&amp;quot;OS_TYPE&amp;quot;];&lt;br /&gt;
             if (sysType == &amp;quot;Win&amp;quot;) &lt;br /&gt;
             {&lt;br /&gt;
                 return new WinFactory();&lt;br /&gt;
             } &lt;br /&gt;
             else &lt;br /&gt;
             {&lt;br /&gt;
                 return new OSXFactory();&lt;br /&gt;
             }&lt;br /&gt;
         } &lt;br /&gt;
 &lt;br /&gt;
         static void Main(string[] args) // Executes first&lt;br /&gt;
         {&lt;br /&gt;
             new Application(CreateOsSpecificFactory());&lt;br /&gt;
             Console.ReadLine();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in C# can be found in the following sites:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/19240/C-Abstract-Factory-Pattern&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/Patterns/PatternAbstract.aspx&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/c%2523&lt;br /&gt;
&lt;br /&gt;
=== Java ===&lt;br /&gt;
 /* GUIFactory example -- */&lt;br /&gt;
  &lt;br /&gt;
 interface Button {&lt;br /&gt;
     void paint();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 interface GUIFactory {&lt;br /&gt;
     Button createButton();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class Application {&lt;br /&gt;
     public Application(GUIFactory factory) {&lt;br /&gt;
         Button button = factory.createButton();&lt;br /&gt;
         button.paint();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 public class ApplicationRunner {&lt;br /&gt;
     public static void main(String[] args) {&lt;br /&gt;
         new Application(createOsSpecificFactory());&lt;br /&gt;
     }&lt;br /&gt;
  &lt;br /&gt;
     public static GUIFactory createOsSpecificFactory() {&lt;br /&gt;
         int sys = readFromConfigFile(&amp;quot;OS_TYPE&amp;quot;);&lt;br /&gt;
         if (sys == 0) return new WinFactory();&lt;br /&gt;
         else return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*http://en.wikipedia.org/wiki/Abstract_factory_pattern&lt;br /&gt;
&lt;br /&gt;
*Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). [http://it-ebooks.info/book/252/ ''Head First Design Patterns'']&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc Gamma, Erich]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). [http://www.informit.com/articles/article.aspx?p=1398599 &amp;quot;Design Patterns: Abstract Factory&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.codeproject.com/script/Membership/View.aspx?mid=319264 Veeneman, David]] (2009-10-23). [http://www.codeproject.com/Articles/4079/Object-Design-for-the-Perplexed &amp;quot;Object Design for the Perplexed&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [http://www.oodesign.com/abstract-factory-pattern.html &amp;quot;Abstract Factory: Implementation&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/strategy-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Strategy_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Creational_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Behavioral_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Prototype_pattern&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
*Scott Walters (2004). [http://perldesignpatterns.com/?CompositePattern Perl Design Patterns Book]&lt;br /&gt;
&lt;br /&gt;
*Geary, David (13 Sep 2002). [http://www.javaworld.com/javaworld/jw-09-2002/jw-0913-designpatterns.html &amp;quot;A look at the Composite design pattern&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/bridge-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Bridge_pattern&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/bridge&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_(software_concept)&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_method_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/factory-method-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Builder_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/19240/C-Abstract-Factory-Pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.dofactory.com/Patterns/PatternAbstract.aspx&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/abstract-factory-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/abstract_factory/cpp/1&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/abstract_factory/cpp/2&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
*http://r3dux.org/2011/07/an-example-abstract-factory-design-pattern-implementation-in-c/&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71133</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71133"/>
		<updated>2012-11-20T04:04:38Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* C++ */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 /* GUIFactory example */&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Button {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual void paint() = 0;&lt;br /&gt;
     virtual ~Button() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual Button* createButton() = 0;&lt;br /&gt;
     virtual ~GUIFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ~WinFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
          &lt;br /&gt;
     ~OSXFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class Application {&lt;br /&gt;
 public:&lt;br /&gt;
     Application(GUIFactory* factory) {&lt;br /&gt;
         Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
         button-&amp;gt;paint();&lt;br /&gt;
         delete button;&lt;br /&gt;
         delete factory;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
     int sys;&lt;br /&gt;
     std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
     std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
 &lt;br /&gt;
     if (sys == 0) {&lt;br /&gt;
         return new WinFactory();&lt;br /&gt;
     } else {&lt;br /&gt;
         return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     Application application(createOsSpecificFactory());&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in C++ can be found here:&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/cpp/1&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/cpp/2&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://r3dux.org/2011/07/an-example-abstract-factory-design-pattern-implementation-in-c/&lt;br /&gt;
&lt;br /&gt;
===C#===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* GUIFactory example -- */ &lt;br /&gt;
 &lt;br /&gt;
 using System;&lt;br /&gt;
 using System.Configuration;&lt;br /&gt;
 &lt;br /&gt;
 namespace AbstractFactory &lt;br /&gt;
 {&lt;br /&gt;
     public interface IButton &lt;br /&gt;
     {&lt;br /&gt;
         void Paint();&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public interface IGUIFactory &lt;br /&gt;
     {&lt;br /&gt;
         IButton CreateButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class OSXButton : IButton // Executes fourth if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinButton : IButton // Executes fourth if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class OSXFactory : IGUIFactory // Executes third if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new OSXButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinFactory : IGUIFactory // Executes third if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new WinButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class Application &lt;br /&gt;
     {&lt;br /&gt;
         public Application(IGUIFactory factory) &lt;br /&gt;
         {&lt;br /&gt;
             IButton button = factory.CreateButton();&lt;br /&gt;
             button.Paint();&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class ApplicationRunner &lt;br /&gt;
     {&lt;br /&gt;
         static IGUIFactory CreateOsSpecificFactory()  // Executes second&lt;br /&gt;
         {&lt;br /&gt;
             // Contents of App{{Not a typo|.}}Config associated with this C# project&lt;br /&gt;
             //&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
             //&amp;lt;configuration&amp;gt;&lt;br /&gt;
             //  &amp;lt;appSettings&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- Uncomment either Win or OSX OS_TYPE to test --&amp;gt;&lt;br /&gt;
             //    &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;Win&amp;quot; /&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;OSX&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
             //  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
             //&amp;lt;/configuration&amp;gt;&lt;br /&gt;
             string sysType = ConfigurationSettings.AppSettings[&amp;quot;OS_TYPE&amp;quot;];&lt;br /&gt;
             if (sysType == &amp;quot;Win&amp;quot;) &lt;br /&gt;
             {&lt;br /&gt;
                 return new WinFactory();&lt;br /&gt;
             } &lt;br /&gt;
             else &lt;br /&gt;
             {&lt;br /&gt;
                 return new OSXFactory();&lt;br /&gt;
             }&lt;br /&gt;
         } &lt;br /&gt;
 &lt;br /&gt;
         static void Main(string[] args) // Executes first&lt;br /&gt;
         {&lt;br /&gt;
             new Application(CreateOsSpecificFactory());&lt;br /&gt;
             Console.ReadLine();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in C# can be found in the following sites:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/19240/C-Abstract-Factory-Pattern&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/Patterns/PatternAbstract.aspx&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/c%2523&lt;br /&gt;
&lt;br /&gt;
=== Java ===&lt;br /&gt;
 /* GUIFactory example -- */&lt;br /&gt;
  &lt;br /&gt;
 interface Button {&lt;br /&gt;
     void paint();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 interface GUIFactory {&lt;br /&gt;
     Button createButton();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class Application {&lt;br /&gt;
     public Application(GUIFactory factory) {&lt;br /&gt;
         Button button = factory.createButton();&lt;br /&gt;
         button.paint();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 public class ApplicationRunner {&lt;br /&gt;
     public static void main(String[] args) {&lt;br /&gt;
         new Application(createOsSpecificFactory());&lt;br /&gt;
     }&lt;br /&gt;
  &lt;br /&gt;
     public static GUIFactory createOsSpecificFactory() {&lt;br /&gt;
         int sys = readFromConfigFile(&amp;quot;OS_TYPE&amp;quot;);&lt;br /&gt;
         if (sys == 0) return new WinFactory();&lt;br /&gt;
         else return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*http://en.wikipedia.org/wiki/Abstract_factory_pattern&lt;br /&gt;
&lt;br /&gt;
*Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). [http://it-ebooks.info/book/252/ ''Head First Design Patterns'']&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc Gamma, Erich]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). [http://www.informit.com/articles/article.aspx?p=1398599 &amp;quot;Design Patterns: Abstract Factory&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.codeproject.com/script/Membership/View.aspx?mid=319264 Veeneman, David]] (2009-10-23). [http://www.codeproject.com/Articles/4079/Object-Design-for-the-Perplexed &amp;quot;Object Design for the Perplexed&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [http://www.oodesign.com/abstract-factory-pattern.html &amp;quot;Abstract Factory: Implementation&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/strategy-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Strategy_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Creational_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Behavioral_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Prototype_pattern&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
*Scott Walters (2004). [http://perldesignpatterns.com/?CompositePattern Perl Design Patterns Book]&lt;br /&gt;
&lt;br /&gt;
*Geary, David (13 Sep 2002). [http://www.javaworld.com/javaworld/jw-09-2002/jw-0913-designpatterns.html &amp;quot;A look at the Composite design pattern&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/bridge-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Bridge_pattern&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/bridge&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_(software_concept)&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_method_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/factory-method-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Builder_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/19240/C-Abstract-Factory-Pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.dofactory.com/Patterns/PatternAbstract.aspx&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/abstract-factory-pattern.html&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71129</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71129"/>
		<updated>2012-11-20T03:59:42Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 /* GUIFactory example */&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Button {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual void paint() = 0;&lt;br /&gt;
     virtual ~Button() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual Button* createButton() = 0;&lt;br /&gt;
     virtual ~GUIFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ~WinFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
          &lt;br /&gt;
     ~OSXFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class Application {&lt;br /&gt;
 public:&lt;br /&gt;
     Application(GUIFactory* factory) {&lt;br /&gt;
         Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
         button-&amp;gt;paint();&lt;br /&gt;
         delete button;&lt;br /&gt;
         delete factory;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
     int sys;&lt;br /&gt;
     std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
     std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
 &lt;br /&gt;
     if (sys == 0) {&lt;br /&gt;
         return new WinFactory();&lt;br /&gt;
     } else {&lt;br /&gt;
         return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     Application application(createOsSpecificFactory());&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in C++&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/cpp/1&lt;br /&gt;
&lt;br /&gt;
===C#===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* GUIFactory example -- */ &lt;br /&gt;
 &lt;br /&gt;
 using System;&lt;br /&gt;
 using System.Configuration;&lt;br /&gt;
 &lt;br /&gt;
 namespace AbstractFactory &lt;br /&gt;
 {&lt;br /&gt;
     public interface IButton &lt;br /&gt;
     {&lt;br /&gt;
         void Paint();&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public interface IGUIFactory &lt;br /&gt;
     {&lt;br /&gt;
         IButton CreateButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class OSXButton : IButton // Executes fourth if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinButton : IButton // Executes fourth if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class OSXFactory : IGUIFactory // Executes third if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new OSXButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinFactory : IGUIFactory // Executes third if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new WinButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class Application &lt;br /&gt;
     {&lt;br /&gt;
         public Application(IGUIFactory factory) &lt;br /&gt;
         {&lt;br /&gt;
             IButton button = factory.CreateButton();&lt;br /&gt;
             button.Paint();&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class ApplicationRunner &lt;br /&gt;
     {&lt;br /&gt;
         static IGUIFactory CreateOsSpecificFactory()  // Executes second&lt;br /&gt;
         {&lt;br /&gt;
             // Contents of App{{Not a typo|.}}Config associated with this C# project&lt;br /&gt;
             //&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
             //&amp;lt;configuration&amp;gt;&lt;br /&gt;
             //  &amp;lt;appSettings&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- Uncomment either Win or OSX OS_TYPE to test --&amp;gt;&lt;br /&gt;
             //    &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;Win&amp;quot; /&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;OSX&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
             //  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
             //&amp;lt;/configuration&amp;gt;&lt;br /&gt;
             string sysType = ConfigurationSettings.AppSettings[&amp;quot;OS_TYPE&amp;quot;];&lt;br /&gt;
             if (sysType == &amp;quot;Win&amp;quot;) &lt;br /&gt;
             {&lt;br /&gt;
                 return new WinFactory();&lt;br /&gt;
             } &lt;br /&gt;
             else &lt;br /&gt;
             {&lt;br /&gt;
                 return new OSXFactory();&lt;br /&gt;
             }&lt;br /&gt;
         } &lt;br /&gt;
 &lt;br /&gt;
         static void Main(string[] args) // Executes first&lt;br /&gt;
         {&lt;br /&gt;
             new Application(CreateOsSpecificFactory());&lt;br /&gt;
             Console.ReadLine();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in C# can be found in the following sites:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/19240/C-Abstract-Factory-Pattern&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/Patterns/PatternAbstract.aspx&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/c%2523&lt;br /&gt;
&lt;br /&gt;
=== Java ===&lt;br /&gt;
 /* GUIFactory example -- */&lt;br /&gt;
  &lt;br /&gt;
 interface Button {&lt;br /&gt;
     void paint();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 interface GUIFactory {&lt;br /&gt;
     Button createButton();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class Application {&lt;br /&gt;
     public Application(GUIFactory factory) {&lt;br /&gt;
         Button button = factory.createButton();&lt;br /&gt;
         button.paint();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 public class ApplicationRunner {&lt;br /&gt;
     public static void main(String[] args) {&lt;br /&gt;
         new Application(createOsSpecificFactory());&lt;br /&gt;
     }&lt;br /&gt;
  &lt;br /&gt;
     public static GUIFactory createOsSpecificFactory() {&lt;br /&gt;
         int sys = readFromConfigFile(&amp;quot;OS_TYPE&amp;quot;);&lt;br /&gt;
         if (sys == 0) return new WinFactory();&lt;br /&gt;
         else return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*http://en.wikipedia.org/wiki/Abstract_factory_pattern&lt;br /&gt;
&lt;br /&gt;
*Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). [http://it-ebooks.info/book/252/ ''Head First Design Patterns'']&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc Gamma, Erich]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). [http://www.informit.com/articles/article.aspx?p=1398599 &amp;quot;Design Patterns: Abstract Factory&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.codeproject.com/script/Membership/View.aspx?mid=319264 Veeneman, David]] (2009-10-23). [http://www.codeproject.com/Articles/4079/Object-Design-for-the-Perplexed &amp;quot;Object Design for the Perplexed&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [http://www.oodesign.com/abstract-factory-pattern.html &amp;quot;Abstract Factory: Implementation&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/strategy-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Strategy_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Creational_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Behavioral_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Prototype_pattern&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
*Scott Walters (2004). [http://perldesignpatterns.com/?CompositePattern Perl Design Patterns Book]&lt;br /&gt;
&lt;br /&gt;
*Geary, David (13 Sep 2002). [http://www.javaworld.com/javaworld/jw-09-2002/jw-0913-designpatterns.html &amp;quot;A look at the Composite design pattern&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/bridge-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Bridge_pattern&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/bridge&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_(software_concept)&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_method_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/factory-method-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Builder_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/19240/C-Abstract-Factory-Pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.dofactory.com/Patterns/PatternAbstract.aspx&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/abstract-factory-pattern.html&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71112</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71112"/>
		<updated>2012-11-20T03:34:25Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* C++ */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 /* GUIFactory example */&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Button {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual void paint() = 0;&lt;br /&gt;
     virtual ~Button() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual Button* createButton() = 0;&lt;br /&gt;
     virtual ~GUIFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ~WinFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
          &lt;br /&gt;
     ~OSXFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class Application {&lt;br /&gt;
 public:&lt;br /&gt;
     Application(GUIFactory* factory) {&lt;br /&gt;
         Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
         button-&amp;gt;paint();&lt;br /&gt;
         delete button;&lt;br /&gt;
         delete factory;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
     int sys;&lt;br /&gt;
     std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
     std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
 &lt;br /&gt;
     if (sys == 0) {&lt;br /&gt;
         return new WinFactory();&lt;br /&gt;
     } else {&lt;br /&gt;
         return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     Application application(createOsSpecificFactory());&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in C++&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/cpp/1&lt;br /&gt;
&lt;br /&gt;
===C#===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* GUIFactory example -- */ &lt;br /&gt;
 &lt;br /&gt;
 using System;&lt;br /&gt;
 using System.Configuration;&lt;br /&gt;
 &lt;br /&gt;
 namespace AbstractFactory &lt;br /&gt;
 {&lt;br /&gt;
     public interface IButton &lt;br /&gt;
     {&lt;br /&gt;
         void Paint();&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public interface IGUIFactory &lt;br /&gt;
     {&lt;br /&gt;
         IButton CreateButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class OSXButton : IButton // Executes fourth if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinButton : IButton // Executes fourth if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class OSXFactory : IGUIFactory // Executes third if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new OSXButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinFactory : IGUIFactory // Executes third if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new WinButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class Application &lt;br /&gt;
     {&lt;br /&gt;
         public Application(IGUIFactory factory) &lt;br /&gt;
         {&lt;br /&gt;
             IButton button = factory.CreateButton();&lt;br /&gt;
             button.Paint();&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class ApplicationRunner &lt;br /&gt;
     {&lt;br /&gt;
         static IGUIFactory CreateOsSpecificFactory()  // Executes second&lt;br /&gt;
         {&lt;br /&gt;
             // Contents of App{{Not a typo|.}}Config associated with this C# project&lt;br /&gt;
             //&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
             //&amp;lt;configuration&amp;gt;&lt;br /&gt;
             //  &amp;lt;appSettings&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- Uncomment either Win or OSX OS_TYPE to test --&amp;gt;&lt;br /&gt;
             //    &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;Win&amp;quot; /&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;OSX&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
             //  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
             //&amp;lt;/configuration&amp;gt;&lt;br /&gt;
             string sysType = ConfigurationSettings.AppSettings[&amp;quot;OS_TYPE&amp;quot;];&lt;br /&gt;
             if (sysType == &amp;quot;Win&amp;quot;) &lt;br /&gt;
             {&lt;br /&gt;
                 return new WinFactory();&lt;br /&gt;
             } &lt;br /&gt;
             else &lt;br /&gt;
             {&lt;br /&gt;
                 return new OSXFactory();&lt;br /&gt;
             }&lt;br /&gt;
         } &lt;br /&gt;
 &lt;br /&gt;
         static void Main(string[] args) // Executes first&lt;br /&gt;
         {&lt;br /&gt;
             new Application(CreateOsSpecificFactory());&lt;br /&gt;
             Console.ReadLine();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in C# can be found in the following sites:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/19240/C-Abstract-Factory-Pattern&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/Patterns/PatternAbstract.aspx&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/c%2523&lt;br /&gt;
&lt;br /&gt;
=== Java ===&lt;br /&gt;
 /* GUIFactory example -- */&lt;br /&gt;
  &lt;br /&gt;
 interface Button {&lt;br /&gt;
     void paint();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 interface GUIFactory {&lt;br /&gt;
     Button createButton();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class Application {&lt;br /&gt;
     public Application(GUIFactory factory) {&lt;br /&gt;
         Button button = factory.createButton();&lt;br /&gt;
         button.paint();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 public class ApplicationRunner {&lt;br /&gt;
     public static void main(String[] args) {&lt;br /&gt;
         new Application(createOsSpecificFactory());&lt;br /&gt;
     }&lt;br /&gt;
  &lt;br /&gt;
     public static GUIFactory createOsSpecificFactory() {&lt;br /&gt;
         int sys = readFromConfigFile(&amp;quot;OS_TYPE&amp;quot;);&lt;br /&gt;
         if (sys == 0) return new WinFactory();&lt;br /&gt;
         else return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*http://en.wikipedia.org/wiki/Abstract_factory_pattern&lt;br /&gt;
&lt;br /&gt;
*Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). [http://it-ebooks.info/book/252/ ''Head First Design Patterns'']&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc Gamma, Erich]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). [http://www.informit.com/articles/article.aspx?p=1398599 &amp;quot;Design Patterns: Abstract Factory&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.codeproject.com/script/Membership/View.aspx?mid=319264 Veeneman, David]] (2009-10-23). [http://www.codeproject.com/Articles/4079/Object-Design-for-the-Perplexed &amp;quot;Object Design for the Perplexed&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [http://www.oodesign.com/abstract-factory-pattern.html &amp;quot;Abstract Factory: Implementation&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/strategy-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Strategy_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Creational_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Behavioral_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Prototype_pattern&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
*Scott Walters (2004). [http://perldesignpatterns.com/?CompositePattern Perl Design Patterns Book]&lt;br /&gt;
&lt;br /&gt;
*Geary, David (13 Sep 2002). [http://www.javaworld.com/javaworld/jw-09-2002/jw-0913-designpatterns.html &amp;quot;A look at the Composite design pattern&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/bridge-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Bridge_pattern&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/bridge&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_(software_concept)&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_method_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/factory-method-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Builder_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/19240/C-Abstract-Factory-Pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.dofactory.com/Patterns/PatternAbstract.aspx&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71110</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71110"/>
		<updated>2012-11-20T03:33:26Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* C# */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 /* GUIFactory example */&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Button {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual void paint() = 0;&lt;br /&gt;
     virtual ~Button() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual Button* createButton() = 0;&lt;br /&gt;
     virtual ~GUIFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ~WinFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
          &lt;br /&gt;
     ~OSXFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class Application {&lt;br /&gt;
 public:&lt;br /&gt;
     Application(GUIFactory* factory) {&lt;br /&gt;
         Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
         button-&amp;gt;paint();&lt;br /&gt;
         delete button;&lt;br /&gt;
         delete factory;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
     int sys;&lt;br /&gt;
     std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
     std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
 &lt;br /&gt;
     if (sys == 0) {&lt;br /&gt;
         return new WinFactory();&lt;br /&gt;
     } else {&lt;br /&gt;
         return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     Application application(createOsSpecificFactory());&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===C#===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* GUIFactory example -- */ &lt;br /&gt;
 &lt;br /&gt;
 using System;&lt;br /&gt;
 using System.Configuration;&lt;br /&gt;
 &lt;br /&gt;
 namespace AbstractFactory &lt;br /&gt;
 {&lt;br /&gt;
     public interface IButton &lt;br /&gt;
     {&lt;br /&gt;
         void Paint();&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public interface IGUIFactory &lt;br /&gt;
     {&lt;br /&gt;
         IButton CreateButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class OSXButton : IButton // Executes fourth if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinButton : IButton // Executes fourth if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class OSXFactory : IGUIFactory // Executes third if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new OSXButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinFactory : IGUIFactory // Executes third if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new WinButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class Application &lt;br /&gt;
     {&lt;br /&gt;
         public Application(IGUIFactory factory) &lt;br /&gt;
         {&lt;br /&gt;
             IButton button = factory.CreateButton();&lt;br /&gt;
             button.Paint();&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class ApplicationRunner &lt;br /&gt;
     {&lt;br /&gt;
         static IGUIFactory CreateOsSpecificFactory()  // Executes second&lt;br /&gt;
         {&lt;br /&gt;
             // Contents of App{{Not a typo|.}}Config associated with this C# project&lt;br /&gt;
             //&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
             //&amp;lt;configuration&amp;gt;&lt;br /&gt;
             //  &amp;lt;appSettings&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- Uncomment either Win or OSX OS_TYPE to test --&amp;gt;&lt;br /&gt;
             //    &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;Win&amp;quot; /&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;OSX&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
             //  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
             //&amp;lt;/configuration&amp;gt;&lt;br /&gt;
             string sysType = ConfigurationSettings.AppSettings[&amp;quot;OS_TYPE&amp;quot;];&lt;br /&gt;
             if (sysType == &amp;quot;Win&amp;quot;) &lt;br /&gt;
             {&lt;br /&gt;
                 return new WinFactory();&lt;br /&gt;
             } &lt;br /&gt;
             else &lt;br /&gt;
             {&lt;br /&gt;
                 return new OSXFactory();&lt;br /&gt;
             }&lt;br /&gt;
         } &lt;br /&gt;
 &lt;br /&gt;
         static void Main(string[] args) // Executes first&lt;br /&gt;
         {&lt;br /&gt;
             new Application(CreateOsSpecificFactory());&lt;br /&gt;
             Console.ReadLine();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in C# can be found in the following sites:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/19240/C-Abstract-Factory-Pattern&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/Patterns/PatternAbstract.aspx&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/abstract_factory/c%2523&lt;br /&gt;
&lt;br /&gt;
=== Java ===&lt;br /&gt;
 /* GUIFactory example -- */&lt;br /&gt;
  &lt;br /&gt;
 interface Button {&lt;br /&gt;
     void paint();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 interface GUIFactory {&lt;br /&gt;
     Button createButton();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class Application {&lt;br /&gt;
     public Application(GUIFactory factory) {&lt;br /&gt;
         Button button = factory.createButton();&lt;br /&gt;
         button.paint();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 public class ApplicationRunner {&lt;br /&gt;
     public static void main(String[] args) {&lt;br /&gt;
         new Application(createOsSpecificFactory());&lt;br /&gt;
     }&lt;br /&gt;
  &lt;br /&gt;
     public static GUIFactory createOsSpecificFactory() {&lt;br /&gt;
         int sys = readFromConfigFile(&amp;quot;OS_TYPE&amp;quot;);&lt;br /&gt;
         if (sys == 0) return new WinFactory();&lt;br /&gt;
         else return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*http://en.wikipedia.org/wiki/Abstract_factory_pattern&lt;br /&gt;
&lt;br /&gt;
*Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). [http://it-ebooks.info/book/252/ ''Head First Design Patterns'']&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc Gamma, Erich]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). [http://www.informit.com/articles/article.aspx?p=1398599 &amp;quot;Design Patterns: Abstract Factory&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.codeproject.com/script/Membership/View.aspx?mid=319264 Veeneman, David]] (2009-10-23). [http://www.codeproject.com/Articles/4079/Object-Design-for-the-Perplexed &amp;quot;Object Design for the Perplexed&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [http://www.oodesign.com/abstract-factory-pattern.html &amp;quot;Abstract Factory: Implementation&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/strategy-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Strategy_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Creational_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Behavioral_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Prototype_pattern&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
*Scott Walters (2004). [http://perldesignpatterns.com/?CompositePattern Perl Design Patterns Book]&lt;br /&gt;
&lt;br /&gt;
*Geary, David (13 Sep 2002). [http://www.javaworld.com/javaworld/jw-09-2002/jw-0913-designpatterns.html &amp;quot;A look at the Composite design pattern&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/bridge-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Bridge_pattern&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/bridge&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_(software_concept)&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_method_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/factory-method-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Builder_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/19240/C-Abstract-Factory-Pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.dofactory.com/Patterns/PatternAbstract.aspx&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71105</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71105"/>
		<updated>2012-11-20T03:30:18Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 /* GUIFactory example */&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Button {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual void paint() = 0;&lt;br /&gt;
     virtual ~Button() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual Button* createButton() = 0;&lt;br /&gt;
     virtual ~GUIFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ~WinFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
          &lt;br /&gt;
     ~OSXFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class Application {&lt;br /&gt;
 public:&lt;br /&gt;
     Application(GUIFactory* factory) {&lt;br /&gt;
         Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
         button-&amp;gt;paint();&lt;br /&gt;
         delete button;&lt;br /&gt;
         delete factory;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
     int sys;&lt;br /&gt;
     std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
     std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
 &lt;br /&gt;
     if (sys == 0) {&lt;br /&gt;
         return new WinFactory();&lt;br /&gt;
     } else {&lt;br /&gt;
         return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     Application application(createOsSpecificFactory());&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===C#===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* GUIFactory example -- */ &lt;br /&gt;
 &lt;br /&gt;
 using System;&lt;br /&gt;
 using System.Configuration;&lt;br /&gt;
 &lt;br /&gt;
 namespace AbstractFactory &lt;br /&gt;
 {&lt;br /&gt;
     public interface IButton &lt;br /&gt;
     {&lt;br /&gt;
         void Paint();&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public interface IGUIFactory &lt;br /&gt;
     {&lt;br /&gt;
         IButton CreateButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class OSXButton : IButton // Executes fourth if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinButton : IButton // Executes fourth if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class OSXFactory : IGUIFactory // Executes third if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new OSXButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinFactory : IGUIFactory // Executes third if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new WinButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class Application &lt;br /&gt;
     {&lt;br /&gt;
         public Application(IGUIFactory factory) &lt;br /&gt;
         {&lt;br /&gt;
             IButton button = factory.CreateButton();&lt;br /&gt;
             button.Paint();&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class ApplicationRunner &lt;br /&gt;
     {&lt;br /&gt;
         static IGUIFactory CreateOsSpecificFactory()  // Executes second&lt;br /&gt;
         {&lt;br /&gt;
             // Contents of App{{Not a typo|.}}Config associated with this C# project&lt;br /&gt;
             //&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
             //&amp;lt;configuration&amp;gt;&lt;br /&gt;
             //  &amp;lt;appSettings&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- Uncomment either Win or OSX OS_TYPE to test --&amp;gt;&lt;br /&gt;
             //    &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;Win&amp;quot; /&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;OSX&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
             //  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
             //&amp;lt;/configuration&amp;gt;&lt;br /&gt;
             string sysType = ConfigurationSettings.AppSettings[&amp;quot;OS_TYPE&amp;quot;];&lt;br /&gt;
             if (sysType == &amp;quot;Win&amp;quot;) &lt;br /&gt;
             {&lt;br /&gt;
                 return new WinFactory();&lt;br /&gt;
             } &lt;br /&gt;
             else &lt;br /&gt;
             {&lt;br /&gt;
                 return new OSXFactory();&lt;br /&gt;
             }&lt;br /&gt;
         } &lt;br /&gt;
 &lt;br /&gt;
         static void Main(string[] args) // Executes first&lt;br /&gt;
         {&lt;br /&gt;
             new Application(CreateOsSpecificFactory());&lt;br /&gt;
             Console.ReadLine();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in C# can be found in the following sites:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/19240/C-Abstract-Factory-Pattern&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/Patterns/PatternAbstract.aspx&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
=== Java ===&lt;br /&gt;
 /* GUIFactory example -- */&lt;br /&gt;
  &lt;br /&gt;
 interface Button {&lt;br /&gt;
     void paint();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 interface GUIFactory {&lt;br /&gt;
     Button createButton();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class Application {&lt;br /&gt;
     public Application(GUIFactory factory) {&lt;br /&gt;
         Button button = factory.createButton();&lt;br /&gt;
         button.paint();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 public class ApplicationRunner {&lt;br /&gt;
     public static void main(String[] args) {&lt;br /&gt;
         new Application(createOsSpecificFactory());&lt;br /&gt;
     }&lt;br /&gt;
  &lt;br /&gt;
     public static GUIFactory createOsSpecificFactory() {&lt;br /&gt;
         int sys = readFromConfigFile(&amp;quot;OS_TYPE&amp;quot;);&lt;br /&gt;
         if (sys == 0) return new WinFactory();&lt;br /&gt;
         else return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*http://en.wikipedia.org/wiki/Abstract_factory_pattern&lt;br /&gt;
&lt;br /&gt;
*Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). [http://it-ebooks.info/book/252/ ''Head First Design Patterns'']&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc Gamma, Erich]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). [http://www.informit.com/articles/article.aspx?p=1398599 &amp;quot;Design Patterns: Abstract Factory&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.codeproject.com/script/Membership/View.aspx?mid=319264 Veeneman, David]] (2009-10-23). [http://www.codeproject.com/Articles/4079/Object-Design-for-the-Perplexed &amp;quot;Object Design for the Perplexed&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [http://www.oodesign.com/abstract-factory-pattern.html &amp;quot;Abstract Factory: Implementation&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/strategy-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Strategy_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Creational_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Behavioral_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Prototype_pattern&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
*Scott Walters (2004). [http://perldesignpatterns.com/?CompositePattern Perl Design Patterns Book]&lt;br /&gt;
&lt;br /&gt;
*Geary, David (13 Sep 2002). [http://www.javaworld.com/javaworld/jw-09-2002/jw-0913-designpatterns.html &amp;quot;A look at the Composite design pattern&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/bridge-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Bridge_pattern&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/bridge&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_(software_concept)&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_method_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/factory-method-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Builder_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/19240/C-Abstract-Factory-Pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.dofactory.com/Patterns/PatternAbstract.aspx&lt;br /&gt;
&lt;br /&gt;
*http://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71103</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71103"/>
		<updated>2012-11-20T03:29:38Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* C# */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 /* GUIFactory example */&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Button {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual void paint() = 0;&lt;br /&gt;
     virtual ~Button() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual Button* createButton() = 0;&lt;br /&gt;
     virtual ~GUIFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ~WinFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
          &lt;br /&gt;
     ~OSXFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class Application {&lt;br /&gt;
 public:&lt;br /&gt;
     Application(GUIFactory* factory) {&lt;br /&gt;
         Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
         button-&amp;gt;paint();&lt;br /&gt;
         delete button;&lt;br /&gt;
         delete factory;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
     int sys;&lt;br /&gt;
     std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
     std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
 &lt;br /&gt;
     if (sys == 0) {&lt;br /&gt;
         return new WinFactory();&lt;br /&gt;
     } else {&lt;br /&gt;
         return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     Application application(createOsSpecificFactory());&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===C#===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* GUIFactory example -- */ &lt;br /&gt;
 &lt;br /&gt;
 using System;&lt;br /&gt;
 using System.Configuration;&lt;br /&gt;
 &lt;br /&gt;
 namespace AbstractFactory &lt;br /&gt;
 {&lt;br /&gt;
     public interface IButton &lt;br /&gt;
     {&lt;br /&gt;
         void Paint();&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public interface IGUIFactory &lt;br /&gt;
     {&lt;br /&gt;
         IButton CreateButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class OSXButton : IButton // Executes fourth if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinButton : IButton // Executes fourth if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class OSXFactory : IGUIFactory // Executes third if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new OSXButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinFactory : IGUIFactory // Executes third if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new WinButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class Application &lt;br /&gt;
     {&lt;br /&gt;
         public Application(IGUIFactory factory) &lt;br /&gt;
         {&lt;br /&gt;
             IButton button = factory.CreateButton();&lt;br /&gt;
             button.Paint();&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class ApplicationRunner &lt;br /&gt;
     {&lt;br /&gt;
         static IGUIFactory CreateOsSpecificFactory()  // Executes second&lt;br /&gt;
         {&lt;br /&gt;
             // Contents of App{{Not a typo|.}}Config associated with this C# project&lt;br /&gt;
             //&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
             //&amp;lt;configuration&amp;gt;&lt;br /&gt;
             //  &amp;lt;appSettings&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- Uncomment either Win or OSX OS_TYPE to test --&amp;gt;&lt;br /&gt;
             //    &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;Win&amp;quot; /&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;OSX&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
             //  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
             //&amp;lt;/configuration&amp;gt;&lt;br /&gt;
             string sysType = ConfigurationSettings.AppSettings[&amp;quot;OS_TYPE&amp;quot;];&lt;br /&gt;
             if (sysType == &amp;quot;Win&amp;quot;) &lt;br /&gt;
             {&lt;br /&gt;
                 return new WinFactory();&lt;br /&gt;
             } &lt;br /&gt;
             else &lt;br /&gt;
             {&lt;br /&gt;
                 return new OSXFactory();&lt;br /&gt;
             }&lt;br /&gt;
         } &lt;br /&gt;
 &lt;br /&gt;
         static void Main(string[] args) // Executes first&lt;br /&gt;
         {&lt;br /&gt;
             new Application(CreateOsSpecificFactory());&lt;br /&gt;
             Console.ReadLine();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
More examples in C# can be found in the following sites:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/19240/C-Abstract-Factory-Pattern&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/Patterns/PatternAbstract.aspx&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
=== Java ===&lt;br /&gt;
 /* GUIFactory example -- */&lt;br /&gt;
  &lt;br /&gt;
 interface Button {&lt;br /&gt;
     void paint();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 interface GUIFactory {&lt;br /&gt;
     Button createButton();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class Application {&lt;br /&gt;
     public Application(GUIFactory factory) {&lt;br /&gt;
         Button button = factory.createButton();&lt;br /&gt;
         button.paint();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 public class ApplicationRunner {&lt;br /&gt;
     public static void main(String[] args) {&lt;br /&gt;
         new Application(createOsSpecificFactory());&lt;br /&gt;
     }&lt;br /&gt;
  &lt;br /&gt;
     public static GUIFactory createOsSpecificFactory() {&lt;br /&gt;
         int sys = readFromConfigFile(&amp;quot;OS_TYPE&amp;quot;);&lt;br /&gt;
         if (sys == 0) return new WinFactory();&lt;br /&gt;
         else return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*http://en.wikipedia.org/wiki/Abstract_factory_pattern&lt;br /&gt;
&lt;br /&gt;
*Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). [http://it-ebooks.info/book/252/ ''Head First Design Patterns'']&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc Gamma, Erich]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). [http://www.informit.com/articles/article.aspx?p=1398599 &amp;quot;Design Patterns: Abstract Factory&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.codeproject.com/script/Membership/View.aspx?mid=319264 Veeneman, David]] (2009-10-23). [http://www.codeproject.com/Articles/4079/Object-Design-for-the-Perplexed &amp;quot;Object Design for the Perplexed&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [http://www.oodesign.com/abstract-factory-pattern.html &amp;quot;Abstract Factory: Implementation&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/strategy-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Strategy_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Creational_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Behavioral_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Prototype_pattern&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
*Scott Walters (2004). [http://perldesignpatterns.com/?CompositePattern Perl Design Patterns Book]&lt;br /&gt;
&lt;br /&gt;
*Geary, David (13 Sep 2002). [http://www.javaworld.com/javaworld/jw-09-2002/jw-0913-designpatterns.html &amp;quot;A look at the Composite design pattern&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/bridge-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Bridge_pattern&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/bridge&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_(software_concept)&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_method_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/factory-method-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Builder_pattern&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71101</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71101"/>
		<updated>2012-11-20T03:26:53Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 /* GUIFactory example */&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Button {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual void paint() = 0;&lt;br /&gt;
     virtual ~Button() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual Button* createButton() = 0;&lt;br /&gt;
     virtual ~GUIFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ~WinFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
          &lt;br /&gt;
     ~OSXFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class Application {&lt;br /&gt;
 public:&lt;br /&gt;
     Application(GUIFactory* factory) {&lt;br /&gt;
         Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
         button-&amp;gt;paint();&lt;br /&gt;
         delete button;&lt;br /&gt;
         delete factory;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
     int sys;&lt;br /&gt;
     std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
     std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
 &lt;br /&gt;
     if (sys == 0) {&lt;br /&gt;
         return new WinFactory();&lt;br /&gt;
     } else {&lt;br /&gt;
         return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     Application application(createOsSpecificFactory());&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===C#===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* GUIFactory example -- */ &lt;br /&gt;
 &lt;br /&gt;
 using System;&lt;br /&gt;
 using System.Configuration;&lt;br /&gt;
 &lt;br /&gt;
 namespace AbstractFactory &lt;br /&gt;
 {&lt;br /&gt;
     public interface IButton &lt;br /&gt;
     {&lt;br /&gt;
         void Paint();&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public interface IGUIFactory &lt;br /&gt;
     {&lt;br /&gt;
         IButton CreateButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class OSXButton : IButton // Executes fourth if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinButton : IButton // Executes fourth if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class OSXFactory : IGUIFactory // Executes third if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new OSXButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinFactory : IGUIFactory // Executes third if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new WinButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class Application &lt;br /&gt;
     {&lt;br /&gt;
         public Application(IGUIFactory factory) &lt;br /&gt;
         {&lt;br /&gt;
             IButton button = factory.CreateButton();&lt;br /&gt;
             button.Paint();&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class ApplicationRunner &lt;br /&gt;
     {&lt;br /&gt;
         static IGUIFactory CreateOsSpecificFactory()  // Executes second&lt;br /&gt;
         {&lt;br /&gt;
             // Contents of App{{Not a typo|.}}Config associated with this C# project&lt;br /&gt;
             //&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
             //&amp;lt;configuration&amp;gt;&lt;br /&gt;
             //  &amp;lt;appSettings&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- Uncomment either Win or OSX OS_TYPE to test --&amp;gt;&lt;br /&gt;
             //    &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;Win&amp;quot; /&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;OSX&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
             //  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
             //&amp;lt;/configuration&amp;gt;&lt;br /&gt;
             string sysType = ConfigurationSettings.AppSettings[&amp;quot;OS_TYPE&amp;quot;];&lt;br /&gt;
             if (sysType == &amp;quot;Win&amp;quot;) &lt;br /&gt;
             {&lt;br /&gt;
                 return new WinFactory();&lt;br /&gt;
             } &lt;br /&gt;
             else &lt;br /&gt;
             {&lt;br /&gt;
                 return new OSXFactory();&lt;br /&gt;
             }&lt;br /&gt;
         } &lt;br /&gt;
 &lt;br /&gt;
         static void Main(string[] args) // Executes first&lt;br /&gt;
         {&lt;br /&gt;
             new Application(CreateOsSpecificFactory());&lt;br /&gt;
             Console.ReadLine();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Java ===&lt;br /&gt;
 /* GUIFactory example -- */&lt;br /&gt;
  &lt;br /&gt;
 interface Button {&lt;br /&gt;
     void paint();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 interface GUIFactory {&lt;br /&gt;
     Button createButton();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class Application {&lt;br /&gt;
     public Application(GUIFactory factory) {&lt;br /&gt;
         Button button = factory.createButton();&lt;br /&gt;
         button.paint();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 public class ApplicationRunner {&lt;br /&gt;
     public static void main(String[] args) {&lt;br /&gt;
         new Application(createOsSpecificFactory());&lt;br /&gt;
     }&lt;br /&gt;
  &lt;br /&gt;
     public static GUIFactory createOsSpecificFactory() {&lt;br /&gt;
         int sys = readFromConfigFile(&amp;quot;OS_TYPE&amp;quot;);&lt;br /&gt;
         if (sys == 0) return new WinFactory();&lt;br /&gt;
         else return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*http://en.wikipedia.org/wiki/Abstract_factory_pattern&lt;br /&gt;
&lt;br /&gt;
*Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). [http://it-ebooks.info/book/252/ ''Head First Design Patterns'']&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc Gamma, Erich]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). [http://www.informit.com/articles/article.aspx?p=1398599 &amp;quot;Design Patterns: Abstract Factory&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.codeproject.com/script/Membership/View.aspx?mid=319264 Veeneman, David]] (2009-10-23). [http://www.codeproject.com/Articles/4079/Object-Design-for-the-Perplexed &amp;quot;Object Design for the Perplexed&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [http://www.oodesign.com/abstract-factory-pattern.html &amp;quot;Abstract Factory: Implementation&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/strategy-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Strategy_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Creational_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Behavioral_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Prototype_pattern&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
*Scott Walters (2004). [http://perldesignpatterns.com/?CompositePattern Perl Design Patterns Book]&lt;br /&gt;
&lt;br /&gt;
*Geary, David (13 Sep 2002). [http://www.javaworld.com/javaworld/jw-09-2002/jw-0913-designpatterns.html &amp;quot;A look at the Composite design pattern&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/bridge-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Bridge_pattern&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/bridge&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_(software_concept)&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_method_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/factory-method-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Builder_pattern&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71100</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71100"/>
		<updated>2012-11-20T03:25:46Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 /* GUIFactory example */&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Button {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual void paint() = 0;&lt;br /&gt;
     virtual ~Button() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual Button* createButton() = 0;&lt;br /&gt;
     virtual ~GUIFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ~WinFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
          &lt;br /&gt;
     ~OSXFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class Application {&lt;br /&gt;
 public:&lt;br /&gt;
     Application(GUIFactory* factory) {&lt;br /&gt;
         Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
         button-&amp;gt;paint();&lt;br /&gt;
         delete button;&lt;br /&gt;
         delete factory;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
     int sys;&lt;br /&gt;
     std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
     std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
 &lt;br /&gt;
     if (sys == 0) {&lt;br /&gt;
         return new WinFactory();&lt;br /&gt;
     } else {&lt;br /&gt;
         return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     Application application(createOsSpecificFactory());&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===C#===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* GUIFactory example -- */ &lt;br /&gt;
 &lt;br /&gt;
 using System;&lt;br /&gt;
 using System.Configuration;&lt;br /&gt;
 &lt;br /&gt;
 namespace AbstractFactory &lt;br /&gt;
 {&lt;br /&gt;
     public interface IButton &lt;br /&gt;
     {&lt;br /&gt;
         void Paint();&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public interface IGUIFactory &lt;br /&gt;
     {&lt;br /&gt;
         IButton CreateButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class OSXButton : IButton // Executes fourth if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinButton : IButton // Executes fourth if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class OSXFactory : IGUIFactory // Executes third if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new OSXButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinFactory : IGUIFactory // Executes third if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new WinButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class Application &lt;br /&gt;
     {&lt;br /&gt;
         public Application(IGUIFactory factory) &lt;br /&gt;
         {&lt;br /&gt;
             IButton button = factory.CreateButton();&lt;br /&gt;
             button.Paint();&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class ApplicationRunner &lt;br /&gt;
     {&lt;br /&gt;
         static IGUIFactory CreateOsSpecificFactory()  // Executes second&lt;br /&gt;
         {&lt;br /&gt;
             // Contents of App{{Not a typo|.}}Config associated with this C# project&lt;br /&gt;
             //&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
             //&amp;lt;configuration&amp;gt;&lt;br /&gt;
             //  &amp;lt;appSettings&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- Uncomment either Win or OSX OS_TYPE to test --&amp;gt;&lt;br /&gt;
             //    &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;Win&amp;quot; /&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;OSX&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
             //  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
             //&amp;lt;/configuration&amp;gt;&lt;br /&gt;
             string sysType = ConfigurationSettings.AppSettings[&amp;quot;OS_TYPE&amp;quot;];&lt;br /&gt;
             if (sysType == &amp;quot;Win&amp;quot;) &lt;br /&gt;
             {&lt;br /&gt;
                 return new WinFactory();&lt;br /&gt;
             } &lt;br /&gt;
             else &lt;br /&gt;
             {&lt;br /&gt;
                 return new OSXFactory();&lt;br /&gt;
             }&lt;br /&gt;
         } &lt;br /&gt;
 &lt;br /&gt;
         static void Main(string[] args) // Executes first&lt;br /&gt;
         {&lt;br /&gt;
             new Application(CreateOsSpecificFactory());&lt;br /&gt;
             Console.ReadLine();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Java ===&lt;br /&gt;
 /* GUIFactory example -- */&lt;br /&gt;
  &lt;br /&gt;
 interface Button {&lt;br /&gt;
     void paint();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 interface GUIFactory {&lt;br /&gt;
     Button createButton();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class Application {&lt;br /&gt;
     public Application(GUIFactory factory) {&lt;br /&gt;
         Button button = factory.createButton();&lt;br /&gt;
         button.paint();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 public class ApplicationRunner {&lt;br /&gt;
     public static void main(String[] args) {&lt;br /&gt;
         new Application(createOsSpecificFactory());&lt;br /&gt;
     }&lt;br /&gt;
  &lt;br /&gt;
     public static GUIFactory createOsSpecificFactory() {&lt;br /&gt;
         int sys = readFromConfigFile(&amp;quot;OS_TYPE&amp;quot;);&lt;br /&gt;
         if (sys == 0) return new WinFactory();&lt;br /&gt;
         else return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*http://en.wikipedia.org/wiki/Abstract_factory_pattern&lt;br /&gt;
&lt;br /&gt;
*Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). [http://it-ebooks.info/book/252/ ''Head First Design Patterns'']&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc Gamma, Erich]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). [http://www.informit.com/articles/article.aspx?p=1398599 &amp;quot;Design Patterns: Abstract Factory&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.codeproject.com/script/Membership/View.aspx?mid=319264 Veeneman, David]] (2009-10-23). [http://www.codeproject.com/Articles/4079/Object-Design-for-the-Perplexed &amp;quot;Object Design for the Perplexed&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/strategy-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Strategy_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Creational_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Behavioral_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Prototype_pattern&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
*Scott Walters (2004). [http://perldesignpatterns.com/?CompositePattern Perl Design Patterns Book]&lt;br /&gt;
&lt;br /&gt;
*Geary, David (13 Sep 2002). [http://www.javaworld.com/javaworld/jw-09-2002/jw-0913-designpatterns.html &amp;quot;A look at the Composite design pattern&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/bridge-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Bridge_pattern&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/bridge&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_(software_concept)&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_method_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/factory-method-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Builder_pattern&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71098</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71098"/>
		<updated>2012-11-20T03:23:53Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 /* GUIFactory example */&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Button {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual void paint() = 0;&lt;br /&gt;
     virtual ~Button() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual Button* createButton() = 0;&lt;br /&gt;
     virtual ~GUIFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ~WinFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
          &lt;br /&gt;
     ~OSXFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class Application {&lt;br /&gt;
 public:&lt;br /&gt;
     Application(GUIFactory* factory) {&lt;br /&gt;
         Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
         button-&amp;gt;paint();&lt;br /&gt;
         delete button;&lt;br /&gt;
         delete factory;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
     int sys;&lt;br /&gt;
     std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
     std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
 &lt;br /&gt;
     if (sys == 0) {&lt;br /&gt;
         return new WinFactory();&lt;br /&gt;
     } else {&lt;br /&gt;
         return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     Application application(createOsSpecificFactory());&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===C#===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* GUIFactory example -- */ &lt;br /&gt;
 &lt;br /&gt;
 using System;&lt;br /&gt;
 using System.Configuration;&lt;br /&gt;
 &lt;br /&gt;
 namespace AbstractFactory &lt;br /&gt;
 {&lt;br /&gt;
     public interface IButton &lt;br /&gt;
     {&lt;br /&gt;
         void Paint();&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public interface IGUIFactory &lt;br /&gt;
     {&lt;br /&gt;
         IButton CreateButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class OSXButton : IButton // Executes fourth if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinButton : IButton // Executes fourth if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class OSXFactory : IGUIFactory // Executes third if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new OSXButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinFactory : IGUIFactory // Executes third if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new WinButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class Application &lt;br /&gt;
     {&lt;br /&gt;
         public Application(IGUIFactory factory) &lt;br /&gt;
         {&lt;br /&gt;
             IButton button = factory.CreateButton();&lt;br /&gt;
             button.Paint();&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class ApplicationRunner &lt;br /&gt;
     {&lt;br /&gt;
         static IGUIFactory CreateOsSpecificFactory()  // Executes second&lt;br /&gt;
         {&lt;br /&gt;
             // Contents of App{{Not a typo|.}}Config associated with this C# project&lt;br /&gt;
             //&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
             //&amp;lt;configuration&amp;gt;&lt;br /&gt;
             //  &amp;lt;appSettings&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- Uncomment either Win or OSX OS_TYPE to test --&amp;gt;&lt;br /&gt;
             //    &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;Win&amp;quot; /&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;OSX&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
             //  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
             //&amp;lt;/configuration&amp;gt;&lt;br /&gt;
             string sysType = ConfigurationSettings.AppSettings[&amp;quot;OS_TYPE&amp;quot;];&lt;br /&gt;
             if (sysType == &amp;quot;Win&amp;quot;) &lt;br /&gt;
             {&lt;br /&gt;
                 return new WinFactory();&lt;br /&gt;
             } &lt;br /&gt;
             else &lt;br /&gt;
             {&lt;br /&gt;
                 return new OSXFactory();&lt;br /&gt;
             }&lt;br /&gt;
         } &lt;br /&gt;
 &lt;br /&gt;
         static void Main(string[] args) // Executes first&lt;br /&gt;
         {&lt;br /&gt;
             new Application(CreateOsSpecificFactory());&lt;br /&gt;
             Console.ReadLine();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Java ===&lt;br /&gt;
 /* GUIFactory example -- */&lt;br /&gt;
  &lt;br /&gt;
 interface Button {&lt;br /&gt;
     void paint();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 interface GUIFactory {&lt;br /&gt;
     Button createButton();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class Application {&lt;br /&gt;
     public Application(GUIFactory factory) {&lt;br /&gt;
         Button button = factory.createButton();&lt;br /&gt;
         button.paint();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 public class ApplicationRunner {&lt;br /&gt;
     public static void main(String[] args) {&lt;br /&gt;
         new Application(createOsSpecificFactory());&lt;br /&gt;
     }&lt;br /&gt;
  &lt;br /&gt;
     public static GUIFactory createOsSpecificFactory() {&lt;br /&gt;
         int sys = readFromConfigFile(&amp;quot;OS_TYPE&amp;quot;);&lt;br /&gt;
         if (sys == 0) return new WinFactory();&lt;br /&gt;
         else return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*http://en.wikipedia.org/wiki/Abstract_factory_pattern&lt;br /&gt;
&lt;br /&gt;
*Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). [http://it-ebooks.info/book/252/ ''Head First Design Patterns'']&lt;br /&gt;
&lt;br /&gt;
* [|[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc Gamma, Erich]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). [http://www.informit.com/articles/article.aspx?p=1398599 &amp;quot;Design Patterns: Abstract Factory&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/strategy-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Strategy_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Creational_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Behavioral_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Prototype_pattern&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
*Scott Walters (2004). [http://perldesignpatterns.com/?CompositePattern Perl Design Patterns Book]&lt;br /&gt;
&lt;br /&gt;
*Geary, David (13 Sep 2002). [http://www.javaworld.com/javaworld/jw-09-2002/jw-0913-designpatterns.html &amp;quot;A look at the Composite design pattern&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/bridge-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Bridge_pattern&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/bridge&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_(software_concept)&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_method_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/factory-method-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Builder_pattern&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71095</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71095"/>
		<updated>2012-11-20T03:20:00Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 /* GUIFactory example */&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Button {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual void paint() = 0;&lt;br /&gt;
     virtual ~Button() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual Button* createButton() = 0;&lt;br /&gt;
     virtual ~GUIFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ~WinFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
          &lt;br /&gt;
     ~OSXFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class Application {&lt;br /&gt;
 public:&lt;br /&gt;
     Application(GUIFactory* factory) {&lt;br /&gt;
         Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
         button-&amp;gt;paint();&lt;br /&gt;
         delete button;&lt;br /&gt;
         delete factory;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
     int sys;&lt;br /&gt;
     std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
     std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
 &lt;br /&gt;
     if (sys == 0) {&lt;br /&gt;
         return new WinFactory();&lt;br /&gt;
     } else {&lt;br /&gt;
         return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     Application application(createOsSpecificFactory());&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===C#===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* GUIFactory example -- */ &lt;br /&gt;
 &lt;br /&gt;
 using System;&lt;br /&gt;
 using System.Configuration;&lt;br /&gt;
 &lt;br /&gt;
 namespace AbstractFactory &lt;br /&gt;
 {&lt;br /&gt;
     public interface IButton &lt;br /&gt;
     {&lt;br /&gt;
         void Paint();&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public interface IGUIFactory &lt;br /&gt;
     {&lt;br /&gt;
         IButton CreateButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class OSXButton : IButton // Executes fourth if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinButton : IButton // Executes fourth if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class OSXFactory : IGUIFactory // Executes third if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new OSXButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinFactory : IGUIFactory // Executes third if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new WinButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class Application &lt;br /&gt;
     {&lt;br /&gt;
         public Application(IGUIFactory factory) &lt;br /&gt;
         {&lt;br /&gt;
             IButton button = factory.CreateButton();&lt;br /&gt;
             button.Paint();&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class ApplicationRunner &lt;br /&gt;
     {&lt;br /&gt;
         static IGUIFactory CreateOsSpecificFactory()  // Executes second&lt;br /&gt;
         {&lt;br /&gt;
             // Contents of App{{Not a typo|.}}Config associated with this C# project&lt;br /&gt;
             //&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
             //&amp;lt;configuration&amp;gt;&lt;br /&gt;
             //  &amp;lt;appSettings&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- Uncomment either Win or OSX OS_TYPE to test --&amp;gt;&lt;br /&gt;
             //    &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;Win&amp;quot; /&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;OSX&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
             //  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
             //&amp;lt;/configuration&amp;gt;&lt;br /&gt;
             string sysType = ConfigurationSettings.AppSettings[&amp;quot;OS_TYPE&amp;quot;];&lt;br /&gt;
             if (sysType == &amp;quot;Win&amp;quot;) &lt;br /&gt;
             {&lt;br /&gt;
                 return new WinFactory();&lt;br /&gt;
             } &lt;br /&gt;
             else &lt;br /&gt;
             {&lt;br /&gt;
                 return new OSXFactory();&lt;br /&gt;
             }&lt;br /&gt;
         } &lt;br /&gt;
 &lt;br /&gt;
         static void Main(string[] args) // Executes first&lt;br /&gt;
         {&lt;br /&gt;
             new Application(CreateOsSpecificFactory());&lt;br /&gt;
             Console.ReadLine();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Java ===&lt;br /&gt;
 /* GUIFactory example -- */&lt;br /&gt;
  &lt;br /&gt;
 interface Button {&lt;br /&gt;
     void paint();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 interface GUIFactory {&lt;br /&gt;
     Button createButton();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class Application {&lt;br /&gt;
     public Application(GUIFactory factory) {&lt;br /&gt;
         Button button = factory.createButton();&lt;br /&gt;
         button.paint();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 public class ApplicationRunner {&lt;br /&gt;
     public static void main(String[] args) {&lt;br /&gt;
         new Application(createOsSpecificFactory());&lt;br /&gt;
     }&lt;br /&gt;
  &lt;br /&gt;
     public static GUIFactory createOsSpecificFactory() {&lt;br /&gt;
         int sys = readFromConfigFile(&amp;quot;OS_TYPE&amp;quot;);&lt;br /&gt;
         if (sys == 0) return new WinFactory();&lt;br /&gt;
         else return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/strategy-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Strategy_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Creational_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Behavioral_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Prototype_pattern&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
*Scott Walters (2004). [http://perldesignpatterns.com/?CompositePattern Perl Design Patterns Book]&lt;br /&gt;
&lt;br /&gt;
*Geary, David (13 Sep 2002). [http://www.javaworld.com/javaworld/jw-09-2002/jw-0913-designpatterns.html &amp;quot;A look at the Composite design pattern&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/bridge-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Bridge_pattern&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/bridge&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_(software_concept)&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_method_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/factory-method-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Builder_pattern&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71094</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71094"/>
		<updated>2012-11-20T03:17:43Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 /* GUIFactory example */&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Button {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual void paint() = 0;&lt;br /&gt;
     virtual ~Button() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual Button* createButton() = 0;&lt;br /&gt;
     virtual ~GUIFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ~WinFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
          &lt;br /&gt;
     ~OSXFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class Application {&lt;br /&gt;
 public:&lt;br /&gt;
     Application(GUIFactory* factory) {&lt;br /&gt;
         Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
         button-&amp;gt;paint();&lt;br /&gt;
         delete button;&lt;br /&gt;
         delete factory;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
     int sys;&lt;br /&gt;
     std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
     std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
 &lt;br /&gt;
     if (sys == 0) {&lt;br /&gt;
         return new WinFactory();&lt;br /&gt;
     } else {&lt;br /&gt;
         return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     Application application(createOsSpecificFactory());&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===C#===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* GUIFactory example -- */ &lt;br /&gt;
 &lt;br /&gt;
 using System;&lt;br /&gt;
 using System.Configuration;&lt;br /&gt;
 &lt;br /&gt;
 namespace AbstractFactory &lt;br /&gt;
 {&lt;br /&gt;
     public interface IButton &lt;br /&gt;
     {&lt;br /&gt;
         void Paint();&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public interface IGUIFactory &lt;br /&gt;
     {&lt;br /&gt;
         IButton CreateButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class OSXButton : IButton // Executes fourth if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinButton : IButton // Executes fourth if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class OSXFactory : IGUIFactory // Executes third if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new OSXButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinFactory : IGUIFactory // Executes third if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new WinButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class Application &lt;br /&gt;
     {&lt;br /&gt;
         public Application(IGUIFactory factory) &lt;br /&gt;
         {&lt;br /&gt;
             IButton button = factory.CreateButton();&lt;br /&gt;
             button.Paint();&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class ApplicationRunner &lt;br /&gt;
     {&lt;br /&gt;
         static IGUIFactory CreateOsSpecificFactory()  // Executes second&lt;br /&gt;
         {&lt;br /&gt;
             // Contents of App{{Not a typo|.}}Config associated with this C# project&lt;br /&gt;
             //&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
             //&amp;lt;configuration&amp;gt;&lt;br /&gt;
             //  &amp;lt;appSettings&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- Uncomment either Win or OSX OS_TYPE to test --&amp;gt;&lt;br /&gt;
             //    &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;Win&amp;quot; /&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;OSX&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
             //  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
             //&amp;lt;/configuration&amp;gt;&lt;br /&gt;
             string sysType = ConfigurationSettings.AppSettings[&amp;quot;OS_TYPE&amp;quot;];&lt;br /&gt;
             if (sysType == &amp;quot;Win&amp;quot;) &lt;br /&gt;
             {&lt;br /&gt;
                 return new WinFactory();&lt;br /&gt;
             } &lt;br /&gt;
             else &lt;br /&gt;
             {&lt;br /&gt;
                 return new OSXFactory();&lt;br /&gt;
             }&lt;br /&gt;
         } &lt;br /&gt;
 &lt;br /&gt;
         static void Main(string[] args) // Executes first&lt;br /&gt;
         {&lt;br /&gt;
             new Application(CreateOsSpecificFactory());&lt;br /&gt;
             Console.ReadLine();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Java ===&lt;br /&gt;
 /* GUIFactory example -- */&lt;br /&gt;
  &lt;br /&gt;
 interface Button {&lt;br /&gt;
     void paint();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 interface GUIFactory {&lt;br /&gt;
     Button createButton();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class Application {&lt;br /&gt;
     public Application(GUIFactory factory) {&lt;br /&gt;
         Button button = factory.createButton();&lt;br /&gt;
         button.paint();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 public class ApplicationRunner {&lt;br /&gt;
     public static void main(String[] args) {&lt;br /&gt;
         new Application(createOsSpecificFactory());&lt;br /&gt;
     }&lt;br /&gt;
  &lt;br /&gt;
     public static GUIFactory createOsSpecificFactory() {&lt;br /&gt;
         int sys = readFromConfigFile(&amp;quot;OS_TYPE&amp;quot;);&lt;br /&gt;
         if (sys == 0) return new WinFactory();&lt;br /&gt;
         else return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/strategy-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Strategy_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Creational_pattern&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Behavioral_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Prototype_pattern&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/bridge-pattern.html&lt;br /&gt;
&lt;br /&gt;
*http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Bridge_pattern&lt;br /&gt;
&lt;br /&gt;
*http://sourcemaking.com/design_patterns/bridge&lt;br /&gt;
&lt;br /&gt;
*http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_(software_concept)&lt;br /&gt;
&lt;br /&gt;
*http://en.wikipedia.org/wiki/Factory_method_pattern&lt;br /&gt;
&lt;br /&gt;
*http://www.oodesign.com/factory-method-pattern.html&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71091</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71091"/>
		<updated>2012-11-20T03:15:17Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Java */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 /* GUIFactory example */&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Button {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual void paint() = 0;&lt;br /&gt;
     virtual ~Button() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual Button* createButton() = 0;&lt;br /&gt;
     virtual ~GUIFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ~WinFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
          &lt;br /&gt;
     ~OSXFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class Application {&lt;br /&gt;
 public:&lt;br /&gt;
     Application(GUIFactory* factory) {&lt;br /&gt;
         Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
         button-&amp;gt;paint();&lt;br /&gt;
         delete button;&lt;br /&gt;
         delete factory;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
     int sys;&lt;br /&gt;
     std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
     std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
 &lt;br /&gt;
     if (sys == 0) {&lt;br /&gt;
         return new WinFactory();&lt;br /&gt;
     } else {&lt;br /&gt;
         return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     Application application(createOsSpecificFactory());&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===C#===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* GUIFactory example -- */ &lt;br /&gt;
 &lt;br /&gt;
 using System;&lt;br /&gt;
 using System.Configuration;&lt;br /&gt;
 &lt;br /&gt;
 namespace AbstractFactory &lt;br /&gt;
 {&lt;br /&gt;
     public interface IButton &lt;br /&gt;
     {&lt;br /&gt;
         void Paint();&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public interface IGUIFactory &lt;br /&gt;
     {&lt;br /&gt;
         IButton CreateButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class OSXButton : IButton // Executes fourth if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinButton : IButton // Executes fourth if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class OSXFactory : IGUIFactory // Executes third if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new OSXButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinFactory : IGUIFactory // Executes third if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new WinButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class Application &lt;br /&gt;
     {&lt;br /&gt;
         public Application(IGUIFactory factory) &lt;br /&gt;
         {&lt;br /&gt;
             IButton button = factory.CreateButton();&lt;br /&gt;
             button.Paint();&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class ApplicationRunner &lt;br /&gt;
     {&lt;br /&gt;
         static IGUIFactory CreateOsSpecificFactory()  // Executes second&lt;br /&gt;
         {&lt;br /&gt;
             // Contents of App{{Not a typo|.}}Config associated with this C# project&lt;br /&gt;
             //&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
             //&amp;lt;configuration&amp;gt;&lt;br /&gt;
             //  &amp;lt;appSettings&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- Uncomment either Win or OSX OS_TYPE to test --&amp;gt;&lt;br /&gt;
             //    &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;Win&amp;quot; /&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;OSX&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
             //  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
             //&amp;lt;/configuration&amp;gt;&lt;br /&gt;
             string sysType = ConfigurationSettings.AppSettings[&amp;quot;OS_TYPE&amp;quot;];&lt;br /&gt;
             if (sysType == &amp;quot;Win&amp;quot;) &lt;br /&gt;
             {&lt;br /&gt;
                 return new WinFactory();&lt;br /&gt;
             } &lt;br /&gt;
             else &lt;br /&gt;
             {&lt;br /&gt;
                 return new OSXFactory();&lt;br /&gt;
             }&lt;br /&gt;
         } &lt;br /&gt;
 &lt;br /&gt;
         static void Main(string[] args) // Executes first&lt;br /&gt;
         {&lt;br /&gt;
             new Application(CreateOsSpecificFactory());&lt;br /&gt;
             Console.ReadLine();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Java ===&lt;br /&gt;
 /* GUIFactory example -- */&lt;br /&gt;
  &lt;br /&gt;
 interface Button {&lt;br /&gt;
     void paint();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 interface GUIFactory {&lt;br /&gt;
     Button createButton();&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXFactory implements GUIFactory {&lt;br /&gt;
     public Button createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class WinButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class OSXButton implements Button {&lt;br /&gt;
     public void paint() {&lt;br /&gt;
         System.out.println(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 class Application {&lt;br /&gt;
     public Application(GUIFactory factory) {&lt;br /&gt;
         Button button = factory.createButton();&lt;br /&gt;
         button.paint();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
  &lt;br /&gt;
 public class ApplicationRunner {&lt;br /&gt;
     public static void main(String[] args) {&lt;br /&gt;
         new Application(createOsSpecificFactory());&lt;br /&gt;
     }&lt;br /&gt;
  &lt;br /&gt;
     public static GUIFactory createOsSpecificFactory() {&lt;br /&gt;
         int sys = readFromConfigFile(&amp;quot;OS_TYPE&amp;quot;);&lt;br /&gt;
         if (sys == 0) return new WinFactory();&lt;br /&gt;
         else return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71089</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71089"/>
		<updated>2012-11-20T03:14:00Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* C# */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 /* GUIFactory example */&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Button {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual void paint() = 0;&lt;br /&gt;
     virtual ~Button() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual Button* createButton() = 0;&lt;br /&gt;
     virtual ~GUIFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ~WinFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
          &lt;br /&gt;
     ~OSXFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class Application {&lt;br /&gt;
 public:&lt;br /&gt;
     Application(GUIFactory* factory) {&lt;br /&gt;
         Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
         button-&amp;gt;paint();&lt;br /&gt;
         delete button;&lt;br /&gt;
         delete factory;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
     int sys;&lt;br /&gt;
     std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
     std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
 &lt;br /&gt;
     if (sys == 0) {&lt;br /&gt;
         return new WinFactory();&lt;br /&gt;
     } else {&lt;br /&gt;
         return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     Application application(createOsSpecificFactory());&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===C#===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 /* GUIFactory example -- */ &lt;br /&gt;
 &lt;br /&gt;
 using System;&lt;br /&gt;
 using System.Configuration;&lt;br /&gt;
 &lt;br /&gt;
 namespace AbstractFactory &lt;br /&gt;
 {&lt;br /&gt;
     public interface IButton &lt;br /&gt;
     {&lt;br /&gt;
         void Paint();&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public interface IGUIFactory &lt;br /&gt;
     {&lt;br /&gt;
         IButton CreateButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class OSXButton : IButton // Executes fourth if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinButton : IButton // Executes fourth if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         public void Paint() &lt;br /&gt;
         {&lt;br /&gt;
             System.Console.WriteLine(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class OSXFactory : IGUIFactory // Executes third if OS:OSX&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new OSXButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class WinFactory : IGUIFactory // Executes third if OS:WIN&lt;br /&gt;
     {&lt;br /&gt;
         IButton IGUIFactory.CreateButton() &lt;br /&gt;
         {&lt;br /&gt;
             return new WinButton();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     public class Application &lt;br /&gt;
     {&lt;br /&gt;
         public Application(IGUIFactory factory) &lt;br /&gt;
         {&lt;br /&gt;
             IButton button = factory.CreateButton();&lt;br /&gt;
             button.Paint();&lt;br /&gt;
         }&lt;br /&gt;
     } &lt;br /&gt;
 &lt;br /&gt;
     public class ApplicationRunner &lt;br /&gt;
     {&lt;br /&gt;
         static IGUIFactory CreateOsSpecificFactory()  // Executes second&lt;br /&gt;
         {&lt;br /&gt;
             // Contents of App{{Not a typo|.}}Config associated with this C# project&lt;br /&gt;
             //&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
             //&amp;lt;configuration&amp;gt;&lt;br /&gt;
             //  &amp;lt;appSettings&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- Uncomment either Win or OSX OS_TYPE to test --&amp;gt;&lt;br /&gt;
             //    &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;Win&amp;quot; /&amp;gt;&lt;br /&gt;
             //    &amp;lt;!-- &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;OSX&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
             //  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
             //&amp;lt;/configuration&amp;gt;&lt;br /&gt;
             string sysType = ConfigurationSettings.AppSettings[&amp;quot;OS_TYPE&amp;quot;];&lt;br /&gt;
             if (sysType == &amp;quot;Win&amp;quot;) &lt;br /&gt;
             {&lt;br /&gt;
                 return new WinFactory();&lt;br /&gt;
             } &lt;br /&gt;
             else &lt;br /&gt;
             {&lt;br /&gt;
                 return new OSXFactory();&lt;br /&gt;
             }&lt;br /&gt;
         } &lt;br /&gt;
 &lt;br /&gt;
         static void Main(string[] args) // Executes first&lt;br /&gt;
         {&lt;br /&gt;
             new Application(CreateOsSpecificFactory());&lt;br /&gt;
             Console.ReadLine();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Java ===&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71087</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71087"/>
		<updated>2012-11-20T03:12:05Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* C++ */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 /* GUIFactory example */&lt;br /&gt;
 &lt;br /&gt;
 #include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 class Button {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual void paint() = 0;&lt;br /&gt;
     virtual ~Button() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXButton : public Button {&lt;br /&gt;
 public:&lt;br /&gt;
     void paint() {&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     virtual Button* createButton() = 0;&lt;br /&gt;
     virtual ~GUIFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class WinFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new WinButton();&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     ~WinFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class OSXFactory : public GUIFactory {&lt;br /&gt;
 public:&lt;br /&gt;
     Button* createButton() {&lt;br /&gt;
         return new OSXButton();&lt;br /&gt;
     }&lt;br /&gt;
          &lt;br /&gt;
     ~OSXFactory() { }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 class Application {&lt;br /&gt;
 public:&lt;br /&gt;
     Application(GUIFactory* factory) {&lt;br /&gt;
         Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
         button-&amp;gt;paint();&lt;br /&gt;
         delete button;&lt;br /&gt;
         delete factory;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
     int sys;&lt;br /&gt;
     std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
     std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
 &lt;br /&gt;
     if (sys == 0) {&lt;br /&gt;
         return new WinFactory();&lt;br /&gt;
     } else {&lt;br /&gt;
         return new OSXFactory();&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 int main() {&lt;br /&gt;
     Application application(createOsSpecificFactory());&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===C#===&lt;br /&gt;
&amp;lt;source lang=CSharp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* GUIFactory example -- */&lt;br /&gt;
&lt;br /&gt;
using System;&lt;br /&gt;
using System.Configuration;&lt;br /&gt;
&lt;br /&gt;
namespace AbstractFactory &lt;br /&gt;
{&lt;br /&gt;
    public interface IButton &lt;br /&gt;
    {&lt;br /&gt;
        void Paint();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public interface IGUIFactory &lt;br /&gt;
    {&lt;br /&gt;
        IButton CreateButton();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class OSXButton : IButton // Executes fourth if OS:OSX&lt;br /&gt;
    {&lt;br /&gt;
        public void Paint() &lt;br /&gt;
        {&lt;br /&gt;
            System.Console.WriteLine(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class WinButton : IButton // Executes fourth if OS:WIN&lt;br /&gt;
    {&lt;br /&gt;
        public void Paint() &lt;br /&gt;
        {&lt;br /&gt;
            System.Console.WriteLine(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class OSXFactory : IGUIFactory // Executes third if OS:OSX&lt;br /&gt;
    {&lt;br /&gt;
        IButton IGUIFactory.CreateButton() &lt;br /&gt;
        {&lt;br /&gt;
            return new OSXButton();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class WinFactory : IGUIFactory // Executes third if OS:WIN&lt;br /&gt;
    {&lt;br /&gt;
        IButton IGUIFactory.CreateButton() &lt;br /&gt;
        {&lt;br /&gt;
            return new WinButton();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class Application &lt;br /&gt;
    {&lt;br /&gt;
        public Application(IGUIFactory factory) &lt;br /&gt;
        {&lt;br /&gt;
            IButton button = factory.CreateButton();&lt;br /&gt;
            button.Paint();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class ApplicationRunner &lt;br /&gt;
    {&lt;br /&gt;
        static IGUIFactory CreateOsSpecificFactory()  // Executes second&lt;br /&gt;
        {&lt;br /&gt;
            // Contents of App{{Not a typo|.}}Config associated with this C# project&lt;br /&gt;
            //&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
            //&amp;lt;configuration&amp;gt;&lt;br /&gt;
            //  &amp;lt;appSettings&amp;gt;&lt;br /&gt;
            //    &amp;lt;!-- Uncomment either Win or OSX OS_TYPE to test --&amp;gt;&lt;br /&gt;
            //    &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;Win&amp;quot; /&amp;gt;&lt;br /&gt;
            //    &amp;lt;!-- &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;OSX&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
            //  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
            //&amp;lt;/configuration&amp;gt;&lt;br /&gt;
            string sysType = ConfigurationSettings.AppSettings[&amp;quot;OS_TYPE&amp;quot;];&lt;br /&gt;
            if (sysType == &amp;quot;Win&amp;quot;) &lt;br /&gt;
            {&lt;br /&gt;
                return new WinFactory();&lt;br /&gt;
            } &lt;br /&gt;
            else &lt;br /&gt;
            {&lt;br /&gt;
                return new OSXFactory();&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) // Executes first&lt;br /&gt;
        {&lt;br /&gt;
            new Application(CreateOsSpecificFactory());&lt;br /&gt;
            Console.ReadLine();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Java ===&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71084</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71084"/>
		<updated>2012-11-20T03:07:57Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&amp;lt;source lang=Cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* GUIFactory example */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
class Button {&lt;br /&gt;
public:&lt;br /&gt;
    virtual void paint() = 0;&lt;br /&gt;
    virtual ~Button() { }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class WinButton : public Button {&lt;br /&gt;
public:&lt;br /&gt;
    void paint() {&lt;br /&gt;
        std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class OSXButton : public Button {&lt;br /&gt;
public:&lt;br /&gt;
    void paint() {&lt;br /&gt;
        std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class GUIFactory {&lt;br /&gt;
public:&lt;br /&gt;
    virtual Button* createButton() = 0;&lt;br /&gt;
    virtual ~GUIFactory() { }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class WinFactory : public GUIFactory {&lt;br /&gt;
public:&lt;br /&gt;
    Button* createButton() {&lt;br /&gt;
        return new WinButton();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ~WinFactory() { }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class OSXFactory : public GUIFactory {&lt;br /&gt;
public:&lt;br /&gt;
    Button* createButton() {&lt;br /&gt;
        return new OSXButton();&lt;br /&gt;
    }&lt;br /&gt;
         &lt;br /&gt;
    ~OSXFactory() { }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class Application {&lt;br /&gt;
public:&lt;br /&gt;
    Application(GUIFactory* factory) {&lt;br /&gt;
        Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
        button-&amp;gt;paint();&lt;br /&gt;
        delete button;&lt;br /&gt;
        delete factory;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
    int sys;&lt;br /&gt;
    std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
    std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
&lt;br /&gt;
    if (sys == 0) {&lt;br /&gt;
        return new WinFactory();&lt;br /&gt;
    } else {&lt;br /&gt;
        return new OSXFactory();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
    Application application(createOsSpecificFactory());&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===C#===&lt;br /&gt;
&amp;lt;source lang=CSharp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* GUIFactory example -- */&lt;br /&gt;
&lt;br /&gt;
using System;&lt;br /&gt;
using System.Configuration;&lt;br /&gt;
&lt;br /&gt;
namespace AbstractFactory &lt;br /&gt;
{&lt;br /&gt;
    public interface IButton &lt;br /&gt;
    {&lt;br /&gt;
        void Paint();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public interface IGUIFactory &lt;br /&gt;
    {&lt;br /&gt;
        IButton CreateButton();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class OSXButton : IButton // Executes fourth if OS:OSX&lt;br /&gt;
    {&lt;br /&gt;
        public void Paint() &lt;br /&gt;
        {&lt;br /&gt;
            System.Console.WriteLine(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class WinButton : IButton // Executes fourth if OS:WIN&lt;br /&gt;
    {&lt;br /&gt;
        public void Paint() &lt;br /&gt;
        {&lt;br /&gt;
            System.Console.WriteLine(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class OSXFactory : IGUIFactory // Executes third if OS:OSX&lt;br /&gt;
    {&lt;br /&gt;
        IButton IGUIFactory.CreateButton() &lt;br /&gt;
        {&lt;br /&gt;
            return new OSXButton();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class WinFactory : IGUIFactory // Executes third if OS:WIN&lt;br /&gt;
    {&lt;br /&gt;
        IButton IGUIFactory.CreateButton() &lt;br /&gt;
        {&lt;br /&gt;
            return new WinButton();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class Application &lt;br /&gt;
    {&lt;br /&gt;
        public Application(IGUIFactory factory) &lt;br /&gt;
        {&lt;br /&gt;
            IButton button = factory.CreateButton();&lt;br /&gt;
            button.Paint();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class ApplicationRunner &lt;br /&gt;
    {&lt;br /&gt;
        static IGUIFactory CreateOsSpecificFactory()  // Executes second&lt;br /&gt;
        {&lt;br /&gt;
            // Contents of App{{Not a typo|.}}Config associated with this C# project&lt;br /&gt;
            //&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
            //&amp;lt;configuration&amp;gt;&lt;br /&gt;
            //  &amp;lt;appSettings&amp;gt;&lt;br /&gt;
            //    &amp;lt;!-- Uncomment either Win or OSX OS_TYPE to test --&amp;gt;&lt;br /&gt;
            //    &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;Win&amp;quot; /&amp;gt;&lt;br /&gt;
            //    &amp;lt;!-- &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;OSX&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
            //  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
            //&amp;lt;/configuration&amp;gt;&lt;br /&gt;
            string sysType = ConfigurationSettings.AppSettings[&amp;quot;OS_TYPE&amp;quot;];&lt;br /&gt;
            if (sysType == &amp;quot;Win&amp;quot;) &lt;br /&gt;
            {&lt;br /&gt;
                return new WinFactory();&lt;br /&gt;
            } &lt;br /&gt;
            else &lt;br /&gt;
            {&lt;br /&gt;
                return new OSXFactory();&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) // Executes first&lt;br /&gt;
        {&lt;br /&gt;
            new Application(CreateOsSpecificFactory());&lt;br /&gt;
            Console.ReadLine();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Java ===&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71082</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71082"/>
		<updated>2012-11-20T03:06:57Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* C# */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&amp;lt;source lang=Cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* GUIFactory example */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
class Button {&lt;br /&gt;
public:&lt;br /&gt;
    virtual void paint() = 0;&lt;br /&gt;
    virtual ~Button() { }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class WinButton : public Button {&lt;br /&gt;
public:&lt;br /&gt;
    void paint() {&lt;br /&gt;
        std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class OSXButton : public Button {&lt;br /&gt;
public:&lt;br /&gt;
    void paint() {&lt;br /&gt;
        std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class GUIFactory {&lt;br /&gt;
public:&lt;br /&gt;
    virtual Button* createButton() = 0;&lt;br /&gt;
    virtual ~GUIFactory() { }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class WinFactory : public GUIFactory {&lt;br /&gt;
public:&lt;br /&gt;
    Button* createButton() {&lt;br /&gt;
        return new WinButton();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ~WinFactory() { }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class OSXFactory : public GUIFactory {&lt;br /&gt;
public:&lt;br /&gt;
    Button* createButton() {&lt;br /&gt;
        return new OSXButton();&lt;br /&gt;
    }&lt;br /&gt;
         &lt;br /&gt;
    ~OSXFactory() { }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class Application {&lt;br /&gt;
public:&lt;br /&gt;
    Application(GUIFactory* factory) {&lt;br /&gt;
        Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
        button-&amp;gt;paint();&lt;br /&gt;
        delete button;&lt;br /&gt;
        delete factory;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
    int sys;&lt;br /&gt;
    std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
    std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
&lt;br /&gt;
    if (sys == 0) {&lt;br /&gt;
        return new WinFactory();&lt;br /&gt;
    } else {&lt;br /&gt;
        return new OSXFactory();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
    Application application(createOsSpecificFactory());&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===C#===&lt;br /&gt;
&amp;lt;source lang=CSharp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* GUIFactory example -- */&lt;br /&gt;
&lt;br /&gt;
using System;&lt;br /&gt;
using System.Configuration;&lt;br /&gt;
&lt;br /&gt;
namespace AbstractFactory &lt;br /&gt;
{&lt;br /&gt;
    public interface IButton &lt;br /&gt;
    {&lt;br /&gt;
        void Paint();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public interface IGUIFactory &lt;br /&gt;
    {&lt;br /&gt;
        IButton CreateButton();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class OSXButton : IButton // Executes fourth if OS:OSX&lt;br /&gt;
    {&lt;br /&gt;
        public void Paint() &lt;br /&gt;
        {&lt;br /&gt;
            System.Console.WriteLine(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class WinButton : IButton // Executes fourth if OS:WIN&lt;br /&gt;
    {&lt;br /&gt;
        public void Paint() &lt;br /&gt;
        {&lt;br /&gt;
            System.Console.WriteLine(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class OSXFactory : IGUIFactory // Executes third if OS:OSX&lt;br /&gt;
    {&lt;br /&gt;
        IButton IGUIFactory.CreateButton() &lt;br /&gt;
        {&lt;br /&gt;
            return new OSXButton();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class WinFactory : IGUIFactory // Executes third if OS:WIN&lt;br /&gt;
    {&lt;br /&gt;
        IButton IGUIFactory.CreateButton() &lt;br /&gt;
        {&lt;br /&gt;
            return new WinButton();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class Application &lt;br /&gt;
    {&lt;br /&gt;
        public Application(IGUIFactory factory) &lt;br /&gt;
        {&lt;br /&gt;
            IButton button = factory.CreateButton();&lt;br /&gt;
            button.Paint();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class ApplicationRunner &lt;br /&gt;
    {&lt;br /&gt;
        static IGUIFactory CreateOsSpecificFactory()  // Executes second&lt;br /&gt;
        {&lt;br /&gt;
            // Contents of App{{Not a typo|.}}Config associated with this C# project&lt;br /&gt;
            //&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
            //&amp;lt;configuration&amp;gt;&lt;br /&gt;
            //  &amp;lt;appSettings&amp;gt;&lt;br /&gt;
            //    &amp;lt;!-- Uncomment either Win or OSX OS_TYPE to test --&amp;gt;&lt;br /&gt;
            //    &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;Win&amp;quot; /&amp;gt;&lt;br /&gt;
            //    &amp;lt;!-- &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;OSX&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
            //  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
            //&amp;lt;/configuration&amp;gt;&lt;br /&gt;
            string sysType = ConfigurationSettings.AppSettings[&amp;quot;OS_TYPE&amp;quot;];&lt;br /&gt;
            if (sysType == &amp;quot;Win&amp;quot;) &lt;br /&gt;
            {&lt;br /&gt;
                return new WinFactory();&lt;br /&gt;
            } &lt;br /&gt;
            else &lt;br /&gt;
            {&lt;br /&gt;
                return new OSXFactory();&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) // Executes first&lt;br /&gt;
        {&lt;br /&gt;
            new Application(CreateOsSpecificFactory());&lt;br /&gt;
            Console.ReadLine();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71081</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71081"/>
		<updated>2012-11-20T03:06:21Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&amp;lt;source lang=Cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* GUIFactory example */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
class Button {&lt;br /&gt;
public:&lt;br /&gt;
    virtual void paint() = 0;&lt;br /&gt;
    virtual ~Button() { }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class WinButton : public Button {&lt;br /&gt;
public:&lt;br /&gt;
    void paint() {&lt;br /&gt;
        std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class OSXButton : public Button {&lt;br /&gt;
public:&lt;br /&gt;
    void paint() {&lt;br /&gt;
        std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class GUIFactory {&lt;br /&gt;
public:&lt;br /&gt;
    virtual Button* createButton() = 0;&lt;br /&gt;
    virtual ~GUIFactory() { }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class WinFactory : public GUIFactory {&lt;br /&gt;
public:&lt;br /&gt;
    Button* createButton() {&lt;br /&gt;
        return new WinButton();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ~WinFactory() { }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class OSXFactory : public GUIFactory {&lt;br /&gt;
public:&lt;br /&gt;
    Button* createButton() {&lt;br /&gt;
        return new OSXButton();&lt;br /&gt;
    }&lt;br /&gt;
         &lt;br /&gt;
    ~OSXFactory() { }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class Application {&lt;br /&gt;
public:&lt;br /&gt;
    Application(GUIFactory* factory) {&lt;br /&gt;
        Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
        button-&amp;gt;paint();&lt;br /&gt;
        delete button;&lt;br /&gt;
        delete factory;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
    int sys;&lt;br /&gt;
    std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
    std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
&lt;br /&gt;
    if (sys == 0) {&lt;br /&gt;
        return new WinFactory();&lt;br /&gt;
    } else {&lt;br /&gt;
        return new OSXFactory();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
    Application application(createOsSpecificFactory());&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===C#===&lt;br /&gt;
&amp;lt;source lang=CSharp&amp;gt;&lt;br /&gt;
/* GUIFactory example -- */&lt;br /&gt;
&lt;br /&gt;
using System;&lt;br /&gt;
using System.Configuration;&lt;br /&gt;
&lt;br /&gt;
namespace AbstractFactory &lt;br /&gt;
{&lt;br /&gt;
    public interface IButton &lt;br /&gt;
    {&lt;br /&gt;
        void Paint();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public interface IGUIFactory &lt;br /&gt;
    {&lt;br /&gt;
        IButton CreateButton();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class OSXButton : IButton // Executes fourth if OS:OSX&lt;br /&gt;
    {&lt;br /&gt;
        public void Paint() &lt;br /&gt;
        {&lt;br /&gt;
            System.Console.WriteLine(&amp;quot;I'm an OSXButton&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class WinButton : IButton // Executes fourth if OS:WIN&lt;br /&gt;
    {&lt;br /&gt;
        public void Paint() &lt;br /&gt;
        {&lt;br /&gt;
            System.Console.WriteLine(&amp;quot;I'm a WinButton&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class OSXFactory : IGUIFactory // Executes third if OS:OSX&lt;br /&gt;
    {&lt;br /&gt;
        IButton IGUIFactory.CreateButton() &lt;br /&gt;
        {&lt;br /&gt;
            return new OSXButton();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class WinFactory : IGUIFactory // Executes third if OS:WIN&lt;br /&gt;
    {&lt;br /&gt;
        IButton IGUIFactory.CreateButton() &lt;br /&gt;
        {&lt;br /&gt;
            return new WinButton();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class Application &lt;br /&gt;
    {&lt;br /&gt;
        public Application(IGUIFactory factory) &lt;br /&gt;
        {&lt;br /&gt;
            IButton button = factory.CreateButton();&lt;br /&gt;
            button.Paint();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public class ApplicationRunner &lt;br /&gt;
    {&lt;br /&gt;
        static IGUIFactory CreateOsSpecificFactory()  // Executes second&lt;br /&gt;
        {&lt;br /&gt;
            // Contents of App{{Not a typo|.}}Config associated with this C# project&lt;br /&gt;
            //&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;
            //&amp;lt;configuration&amp;gt;&lt;br /&gt;
            //  &amp;lt;appSettings&amp;gt;&lt;br /&gt;
            //    &amp;lt;!-- Uncomment either Win or OSX OS_TYPE to test --&amp;gt;&lt;br /&gt;
            //    &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;Win&amp;quot; /&amp;gt;&lt;br /&gt;
            //    &amp;lt;!-- &amp;lt;add key=&amp;quot;OS_TYPE&amp;quot; value=&amp;quot;OSX&amp;quot; /&amp;gt; --&amp;gt;&lt;br /&gt;
            //  &amp;lt;/appSettings&amp;gt;&lt;br /&gt;
            //&amp;lt;/configuration&amp;gt;&lt;br /&gt;
            string sysType = ConfigurationSettings.AppSettings[&amp;quot;OS_TYPE&amp;quot;];&lt;br /&gt;
            if (sysType == &amp;quot;Win&amp;quot;) &lt;br /&gt;
            {&lt;br /&gt;
                return new WinFactory();&lt;br /&gt;
            } &lt;br /&gt;
            else &lt;br /&gt;
            {&lt;br /&gt;
                return new OSXFactory();&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        static void Main(string[] args) // Executes first&lt;br /&gt;
        {&lt;br /&gt;
            new Application(CreateOsSpecificFactory());&lt;br /&gt;
            Console.ReadLine();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71079</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71079"/>
		<updated>2012-11-20T03:05:40Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&amp;lt;source lang=Cpp&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* GUIFactory example */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
class Button {&lt;br /&gt;
public:&lt;br /&gt;
    virtual void paint() = 0;&lt;br /&gt;
    virtual ~Button() { }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class WinButton : public Button {&lt;br /&gt;
public:&lt;br /&gt;
    void paint() {&lt;br /&gt;
        std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class OSXButton : public Button {&lt;br /&gt;
public:&lt;br /&gt;
    void paint() {&lt;br /&gt;
        std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class GUIFactory {&lt;br /&gt;
public:&lt;br /&gt;
    virtual Button* createButton() = 0;&lt;br /&gt;
    virtual ~GUIFactory() { }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class WinFactory : public GUIFactory {&lt;br /&gt;
public:&lt;br /&gt;
    Button* createButton() {&lt;br /&gt;
        return new WinButton();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ~WinFactory() { }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class OSXFactory : public GUIFactory {&lt;br /&gt;
public:&lt;br /&gt;
    Button* createButton() {&lt;br /&gt;
        return new OSXButton();&lt;br /&gt;
    }&lt;br /&gt;
         &lt;br /&gt;
    ~OSXFactory() { }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class Application {&lt;br /&gt;
public:&lt;br /&gt;
    Application(GUIFactory* factory) {&lt;br /&gt;
        Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
        button-&amp;gt;paint();&lt;br /&gt;
        delete button;&lt;br /&gt;
        delete factory;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
    int sys;&lt;br /&gt;
    std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
    std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
&lt;br /&gt;
    if (sys == 0) {&lt;br /&gt;
        return new WinFactory();&lt;br /&gt;
    } else {&lt;br /&gt;
        return new OSXFactory();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
    Application application(createOsSpecificFactory());&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71072</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71072"/>
		<updated>2012-11-20T02:52:08Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
=== C++ ===&lt;br /&gt;
&amp;lt;source lang=Cpp&amp;gt;&lt;br /&gt;
/* GUIFactory example */&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
&lt;br /&gt;
class Button {&lt;br /&gt;
public:&lt;br /&gt;
    virtual void paint() = 0;&lt;br /&gt;
    virtual ~Button() { }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class WinButton : public Button {&lt;br /&gt;
public:&lt;br /&gt;
    void paint() {&lt;br /&gt;
        std::cout &amp;lt;&amp;lt; &amp;quot;I'm a WinButton&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class OSXButton : public Button {&lt;br /&gt;
public:&lt;br /&gt;
    void paint() {&lt;br /&gt;
        std::cout &amp;lt;&amp;lt; &amp;quot;I'm an OSXButton&amp;quot;;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class GUIFactory {&lt;br /&gt;
public:&lt;br /&gt;
    virtual Button* createButton() = 0;&lt;br /&gt;
    virtual ~GUIFactory() { }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class WinFactory : public GUIFactory {&lt;br /&gt;
public:&lt;br /&gt;
    Button* createButton() {&lt;br /&gt;
        return new WinButton();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    ~WinFactory() { }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class OSXFactory : public GUIFactory {&lt;br /&gt;
public:&lt;br /&gt;
    Button* createButton() {&lt;br /&gt;
        return new OSXButton();&lt;br /&gt;
    }&lt;br /&gt;
         &lt;br /&gt;
    ~OSXFactory() { }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
class Application {&lt;br /&gt;
public:&lt;br /&gt;
    Application(GUIFactory* factory) {&lt;br /&gt;
        Button* button = factory-&amp;gt;createButton();&lt;br /&gt;
        button-&amp;gt;paint();&lt;br /&gt;
        delete button;&lt;br /&gt;
        delete factory;&lt;br /&gt;
    }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
GUIFactory* createOsSpecificFactory() {&lt;br /&gt;
    int sys;&lt;br /&gt;
    std::cout &amp;quot;\nEnter OS type (0: Windows, 1: MacOS X): &amp;quot;;&lt;br /&gt;
    std::cin &amp;gt;&amp;gt; sys;&lt;br /&gt;
&lt;br /&gt;
    if (sys == 0) {&lt;br /&gt;
        return new WinFactory();&lt;br /&gt;
    } else {&lt;br /&gt;
        return new OSXFactory();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
    Application application(createOsSpecificFactory());&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71070</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71070"/>
		<updated>2012-11-20T02:51:08Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
In this section, we show implementation examples of the Abstract Factory in different languages. The output of each should be either &amp;quot;I'm a WinButton&amp;quot; or &amp;quot;I'm an OSXButton&amp;quot; depending on which kind of factory was used. Note that the Application has no idea what kind of GUIFactory it is given or even what kind of Button that factory creates. This same code can be found at http://en.wikipedia.org/wiki/Abstract_factory_pattern#Example&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71064</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71064"/>
		<updated>2012-11-20T02:48:13Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71060</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71060"/>
		<updated>2012-11-20T02:47:27Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* UML Diagram */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71059</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71059"/>
		<updated>2012-11-20T02:46:36Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Comparison with other patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
== UML Diagram ==&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Factory Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
=== Bridge Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
=== Builder Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
=== Strategy Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Prototype Pattern ===&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71036</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71036"/>
		<updated>2012-11-20T02:06:34Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
== UML Diagram ==&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Factory Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
== Bridge Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
== Builder Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
== Strategy Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prototype Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71034</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71034"/>
		<updated>2012-11-20T02:06:04Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
The following diagram shows the UML representation of the Abstract Factory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following sites show more UML diagrams with explanantions:&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/331304/Understanding-and-Implementing-Abstract-Factory-Pa&lt;br /&gt;
&lt;br /&gt;
http://apwebco.com/gofpatterns/creational/AbstractFactory.html&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Factory Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
== Bridge Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
== Builder Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
== Strategy Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prototype Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71024</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71024"/>
		<updated>2012-11-20T01:33:14Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Factory Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
== Class Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Factory Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library. The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
== Bridge Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
== Builder Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
== Strategy Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prototype Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71022</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71022"/>
		<updated>2012-11-20T01:32:37Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Factory Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
== Class Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Factory Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Factory_method_pattern Factory Method Pattern] is an object-oriented creational design pattern to implement the concept of [http://en.wikipedia.org/wiki/Factory_(software_concept) factories] and deals with the problem of creating objects (products) without specifying the exact class of object that will be created. The essence of this pattern is to &amp;quot;Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.&lt;br /&gt;
&lt;br /&gt;
Also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using the library.&lt;br /&gt;
&lt;br /&gt;
The Factory method works just the same way: it defines an interface for creating an object, but leaves the choice of its type to the subclasses, creation being deferred at run-time. &lt;br /&gt;
&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object. &lt;br /&gt;
&lt;br /&gt;
The following websites further explain the difference between Abstract Factory and Factory Method in detail.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/1001767/what-is-the-basic-difference-between-factory-and-abstract-factory-patterns&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://www.dofactory.com/topic/1284/abstract-factory-vs-factory-method.aspx&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
== Bridge Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
== Builder Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
== Strategy Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prototype Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71015</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71015"/>
		<updated>2012-11-20T01:22:17Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Bridge Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
== Class Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Factory Pattern ==&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object.Many people do get confused between these two terms and start using them interchangeably.The links to the sites  below gives a good explanation of differences between these two terms and are easy is to follow :&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
== Bridge Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.felix-colibri.com/papers/design_patterns/factory_and_bridge_patterns/factory_and_bridge_patterns.html&lt;br /&gt;
&lt;br /&gt;
== Builder Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
== Strategy Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prototype Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71012</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71012"/>
		<updated>2012-11-20T01:20:13Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Prototype Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
== Class Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Factory Pattern ==&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object.Many people do get confused between these two terms and start using them interchangeably.The links to the sites  below gives a good explanation of differences between these two terms and are easy is to follow :&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
== Bridge Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
== Builder Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
== Strategy Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prototype Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Prototype_pattern prototype pattern] is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71010</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71010"/>
		<updated>2012-11-20T01:19:30Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Bridge Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
== Class Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Factory Pattern ==&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object.Many people do get confused between these two terms and start using them interchangeably.The links to the sites  below gives a good explanation of differences between these two terms and are easy is to follow :&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
== Bridge Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
== Builder Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
== Strategy Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prototype Pattern ==&lt;br /&gt;
The prototype pattern is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71009</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=71009"/>
		<updated>2012-11-20T01:19:13Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Bridge Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
== Class Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Factory Pattern ==&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object.Many people do get confused between these two terms and start using them interchangeably.The links to the sites  below gives a good explanation of differences between these two terms and are easy is to follow :&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
== Bridge Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Bridge Pattern is that sometimes an abstraction may need to  have different implementations: Consider an object that handles persistence of objects over different platforms using either relational databases or file system structures (files and folders). A simple implementation might choose to extend the object itself to implement the functionality for both file system and RDBMS. However this implementation would create a problem: Inheritance binds an implementation to the abstraction and thus it would be difficult to modify, extend, and reuse abstraction and implementation independently.&lt;br /&gt;
&lt;br /&gt;
An Abstract Factory pattern can be used create and configure a particular Bridge, for example a factory can choose the suitable concrete implementor at runtime.&lt;br /&gt;
&lt;br /&gt;
The difference between Abstract Factory and Bridge is further explained in the following sites.&lt;br /&gt;
http://wgao.blogspot.com/2004/11/bridge-pattern-and-abstract-factory.html&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
== Builder Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
== Strategy Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prototype Pattern ==&lt;br /&gt;
The prototype pattern is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70990</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70990"/>
		<updated>2012-11-20T01:06:11Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Prototype Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
== Class Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Factory Pattern ==&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object.Many people do get confused between these two terms and start using them interchangeably.The links to the sites  below gives a good explanation of differences between these two terms and are easy is to follow :&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
== Bridge Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.So how does abstract factory pattern compare with this? &lt;br /&gt;
The site given below explains the differences between abstract factory pattern and the bridge pattern in a non complicated manner:&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Builder Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
== Strategy Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prototype Pattern ==&lt;br /&gt;
The prototype pattern is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70987</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70987"/>
		<updated>2012-11-20T01:05:45Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Comparison with other patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
== Class Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Factory Pattern ==&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object.Many people do get confused between these two terms and start using them interchangeably.The links to the sites  below gives a good explanation of differences between these two terms and are easy is to follow :&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
== Bridge Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.So how does abstract factory pattern compare with this? &lt;br /&gt;
The site given below explains the differences between abstract factory pattern and the bridge pattern in a non complicated manner:&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Builder Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
== Strategy Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prototype Pattern ==&lt;br /&gt;
The prototype pattern is a creational design pattern used in software development when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. &lt;br /&gt;
The motivation behind this pattern is to:&lt;br /&gt;
*avoid subclasses of an object creator in the client application, like the abstract factory pattern does.&lt;br /&gt;
*avoid the inherent cost of creating a new object in the standard way (e.g., using the 'new' keyword) when it is prohibitively expensive for a given application.&lt;br /&gt;
&lt;br /&gt;
Abstract Factory classes are often implemented with Factory Methods, but they can be implemented using Prototype. This concept is further explained in the following sites.&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739240/questions-about-the-prototype-pattern&lt;br /&gt;
http://www.oodesign.com/prototype-pattern.html&lt;br /&gt;
http://sourcemaking.com/design_patterns/prototype&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70975</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70975"/>
		<updated>2012-11-20T00:55:47Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Strategy Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
== Class Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Factory Pattern ==&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object.Many people do get confused between these two terms and start using them interchangeably.The links to the sites  below gives a good explanation of differences between these two terms and are easy is to follow :&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
== Bridge Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.So how does abstract factory pattern compare with this? &lt;br /&gt;
The site given below explains the differences between abstract factory pattern and the bridge pattern in a non complicated manner:&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Builder Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
== Strategy Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Strategy_pattern strategy pattern] (also known as the policy pattern) is a particular software design pattern, whereby algorithms behaviour can be selected at runtime. Formally speaking, the strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.&lt;br /&gt;
&lt;br /&gt;
The motivation behind the Strategy Pattern is that there are situations when classes differ only in their behavior. In such cases, it is a good idea to isolate the algorithms in separate classes in order to have the ability to select different algorithms at runtime. &lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Strategy is that Abstract Factory is a [http://en.wikipedia.org/wiki/Creational_pattern creational pattern] whereas Strategy is a [http://en.wikipedia.org/wiki/Behavioral_pattern behavioral pattern].&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70969</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70969"/>
		<updated>2012-11-20T00:45:28Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Builder Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
== Class Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Factory Pattern ==&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object.Many people do get confused between these two terms and start using them interchangeably.The links to the sites  below gives a good explanation of differences between these two terms and are easy is to follow :&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
== Bridge Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.So how does abstract factory pattern compare with this? &lt;br /&gt;
The site given below explains the differences between abstract factory pattern and the bridge pattern in a non complicated manner:&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Builder Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The main difference between Abstract Factory and Builder is that in the case of the Abstract Factory, the client uses the factory's methods to create its own objects whereas in the Builder's case, the Builder class is instructed on how to create the object and then it is asked for it, but the way that the class is put together is up to the Builder class&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern is explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
http://www.oodesign.com/builder-pattern.html&lt;br /&gt;
&lt;br /&gt;
== Strategy Pattern ==&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70965</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70965"/>
		<updated>2012-11-20T00:40:27Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Abstract Factory: A directory of sites */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The objective of this wiki is to provide a directory of sites that one would refer to while learning about the Abstract Factory pattern. Therefore, in this wiki, we will be giving an overview of the different features of the Abstract Factory pattern along with links to useful websites that explain each of these features in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
== Class Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Factory Pattern ==&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object.Many people do get confused between these two terms and start using them interchangeably.The links to the sites  below gives a good explanation of differences between these two terms and are easy is to follow :&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
== Bridge Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.So how does abstract factory pattern compare with this? &lt;br /&gt;
The site given below explains the differences between abstract factory pattern and the bridge pattern in a non complicated manner:&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Builder Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern are explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
== Strategy Pattern ==&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70956</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70956"/>
		<updated>2012-11-20T00:36:28Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Builder Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In this wiki, we provide an explanation of the Abstract Factory pattern along with links to useful websites that would explain this design pattern in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
== Class Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Factory Pattern ==&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object.Many people do get confused between these two terms and start using them interchangeably.The links to the sites  below gives a good explanation of differences between these two terms and are easy is to follow :&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
== Bridge Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.So how does abstract factory pattern compare with this? &lt;br /&gt;
The site given below explains the differences between abstract factory pattern and the bridge pattern in a non complicated manner:&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Builder Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern]. &lt;br /&gt;
&lt;br /&gt;
The motivation behind the builder pattern is that the complexity of classes and objects which increases as the complexity of the application increases. Complex objects are made of parts produced by other objects that need special care when being built. An application might need a mechanism for building complex objects that is independent from the ones that make up the object. &lt;br /&gt;
&lt;br /&gt;
The builder pattern allows a client object to construct a complex object by specifying only its type and content, being shielded from the details related to the object's representation. This way the construction process can be used to create different representations. The logic of this process is isolated form the actual steps used in creating the complex object, so the process can be used again to create a different object form the same set of simple objects as the first one.&lt;br /&gt;
&lt;br /&gt;
The difference between Builder pattern and the Abstract Factory pattern are explained in detail in the following sites.&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
== Strategy Pattern ==&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70952</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70952"/>
		<updated>2012-11-20T00:32:58Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Comparison with other patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In this wiki, we provide an explanation of the Abstract Factory pattern along with links to useful websites that would explain this design pattern in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
== Class Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Factory Pattern ==&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object.Many people do get confused between these two terms and start using them interchangeably.The links to the sites  below gives a good explanation of differences between these two terms and are easy is to follow :&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
== Bridge Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.So how does abstract factory pattern compare with this? &lt;br /&gt;
The site given below explains the differences between abstract factory pattern and the bridge pattern in a non complicated manner:&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Builder Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Builder_pattern builder pattern] is an [http://en.wikipedia.org/wiki/Creational_pattern object creation] software design pattern. The intention is to abstract steps of construction of objects so that different implementations of these steps can construct different representations of objects. Often, the builder pattern is used to build products in accordance with the [http://en.wikipedia.org/wiki/Composite_pattern composite pattern].&lt;br /&gt;
&lt;br /&gt;
https://sites.google.com/site/sureshdevang/abstract-factory-vs-builder-design-patterns&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/3687299/abstract-factory-factory-method-builder&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Strategy Pattern ==&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4926278/what-the-diffrence-between-strategy-design-pattern-and-abstract-factory-pattern&lt;br /&gt;
&lt;br /&gt;
http://geekswithblogs.net/SanjayU/archive/2009/04/15/another-abstract-factory-amp-strategy-pattern-explanation.aspx&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70922</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70922"/>
		<updated>2012-11-20T00:11:09Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Factory Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In this wiki, we provide an explanation of the Abstract Factory pattern along with links to useful websites that would explain this design pattern in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
== Class Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Factory Pattern ==&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object.Many people do get confused between these two terms and start using them interchangeably.The links to the sites  below gives a good explanation of differences between these two terms and are easy is to follow :&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/4209791/design-patterns-abstract-factory-vs-factory-method&lt;br /&gt;
&lt;br /&gt;
== Bridge Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.So how does abstract factory pattern compare with this? &lt;br /&gt;
The site given below explains the differences between abstract factory pattern and the bridge pattern in a non complicated manner:&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70745</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70745"/>
		<updated>2012-11-19T21:15:01Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Bridge Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In this wiki, we provide an explanation of the Abstract Factory pattern along with links to useful websites that would explain this design pattern in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
== Class Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Factory Pattern ==&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object.Many people do get confused between these two terms and start using them interchangeably.The links to the sites  below gives a good explanation of differences between these two terms and are easy is to follow :&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Bridge Pattern ==&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bridge_pattern bridge pattern] is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.So how does abstract factory pattern compare with this? &lt;br /&gt;
The site given below explains the differences between abstract factory pattern and the bridge pattern in a non complicated manner:&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70734</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70734"/>
		<updated>2012-11-19T21:11:33Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Comparison with other patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In this wiki, we provide an explanation of the Abstract Factory pattern along with links to useful websites that would explain this design pattern in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
== Class Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Factory Pattern ==&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object.Many people do get confused between these two terms and start using them interchangeably.The links to the sites  below gives a good explanation of differences between these two terms and are easy is to follow :&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Bridge Pattern ==&lt;br /&gt;
The bridge pattern is a design pattern used in software engineering which is meant to &amp;quot;decouple an abstraction from its implementation so that the two can vary independently&amp;quot;. The bridge uses encapsulation, aggregation, and can use inheritance to separate responsibilities into different classes.So how does abstract factory pattern compare with this? &lt;br /&gt;
The site given below explains the differences between abstract factory pattern and the bridge pattern in a non complicated manner:&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/7700854/abstractfactory-versus-bridge-pattern&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70730</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70730"/>
		<updated>2012-11-19T21:09:27Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In this wiki, we provide an explanation of the Abstract Factory pattern along with links to useful websites that would explain this design pattern in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
== Class Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
= Comparison with other patterns =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Factory Pattern ==&lt;br /&gt;
The main difference between a &amp;quot;factory method&amp;quot; and an &amp;quot;abstract factory&amp;quot; is that the factory method is a single method, and an abstract factory is an object.Many people do get confused between these two terms and start using them interchangeably.The links to the sites  below gives a good explanation of differences between these two terms and are easy is to follow :&lt;br /&gt;
&lt;br /&gt;
http://stackoverflow.com/questions/5739611/differences-between-abstract-factory-pattern-and-factory-method&lt;br /&gt;
&lt;br /&gt;
http://www.codeproject.com/Articles/35789/Understanding-Factory-Method-and-Abstract-Factory&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70669</id>
		<title>CSC/ECE 517 Fall 2012/ch2b 2w57</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2012/ch2b_2w57&amp;diff=70669"/>
		<updated>2012-11-19T20:11:21Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: /* Structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Abstract Factory: A directory of sites =&lt;br /&gt;
The essence of the Abstract Factory Pattern is to &amp;quot;Provide an interface for creating families of related or dependent objects without specifying their concrete classes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In this wiki, we provide an explanation of the Abstract Factory pattern along with links to useful websites that would explain this design pattern in more detail.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The abstract factory pattern is a software [http://en.wikipedia.org/wiki/Creational_pattern creational] [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) design pattern] that provides a way to encapsulate a group of individual [http://en.wikipedia.org/wiki/Factory_object factories] that have a common theme without specifying their concrete classes. In normal usage, the client software creates a concrete implementation of the abstract factory and then uses the generic interfaces to create the concrete objects that are part of the theme. The client does not know (or care) which concrete objects it gets from each of these internal factories, since it uses only the generic interfaces of their products. This pattern separates the details of implementation of a set of objects from their general usage and relies on object composition, as object creation is implemented in methods exposed in the factory interface.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Motivation ==&lt;br /&gt;
[http://en.wikipedia.org/wiki/Modular_programming Modularization] is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.&lt;br /&gt;
&lt;br /&gt;
In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country. In other words, the Abstract Factory is a super-factory which creates other factories (Factory of factories).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
The factory determines the actual concrete type of object to be created, and it is here that the object is actually created (in C++, for instance, by the new operator). However, the factory only returns an abstract pointer to the created concrete object.&lt;br /&gt;
This insulates client code from object creation by having clients ask a factory object to create an object of the desired abstract type and to return an abstract pointer to the object.&lt;br /&gt;
As the factory only returns an abstract pointer, the client code (that requested the object from the factory) does not know – and is not burdened by – the actual concrete type of the object that was just created. However, the type of a concrete object (and hence a concrete factory) is known by the abstract factory; for instance, the factory may read it from a configuration file. The client has no need to specify the type, since it has already been specified in the configuration file. In particular, this means:&lt;br /&gt;
*The client code has no knowledge whatsoever of the concrete type, not needing to include any header files or class declarations related to it. The client code deals only with the abstract type. Objects of a concrete type are indeed created by the factory, but the client code accesses such objects only through their abstract interface.&lt;br /&gt;
*Adding new concrete types is done by modifying the client code to use a different factory, a modification that is typically one line in one file. (The different factory then creates objects of a different concrete type, but still returns a pointer of the same abstract type as before – thus insulating the client code from change.) This is significantly easier than modifying the client code to instantiate a new type, which would require changing every location in the code where a new object is created (as well as making sure that all such code locations also have knowledge of the new concrete type, by including for instance a concrete class header file). If all factory objects are stored globally in a [http://en.wikipedia.org/wiki/Singleton_pattern singleton] object, and all client code goes through the singleton to access the proper factory for object creation, then changing factories is as easy as changing the singleton object.&lt;br /&gt;
&lt;br /&gt;
= Structure =&lt;br /&gt;
&lt;br /&gt;
== Class Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== UML Diagram ==&lt;br /&gt;
&lt;br /&gt;
[[File:Abstract factory UML.png]]&lt;br /&gt;
&lt;br /&gt;
=References=&lt;br /&gt;
*^ [|Gamma, Erich[http://www.informit.com/authors/bio.aspx?a=725735c6-e618-488a-9f9b-a3b8344570dc]]; Richard Helm, Ralph Johnson, John M. Vlissides (2009-10-23). &amp;quot;Design Patterns: Abstract Factory&amp;quot;. informIT. Archived from the original on 2009-10-23. Retrieved 2012-05-16. &amp;quot;Object Creational: Abstract Factory: Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*a b Freeman, Eric; Freeman, Elisabeth; Kathy, Sierra; Bert, Bates (2004). Hendrickson, Mike. ed (paperback). Head First Design Patterns. 1. O'REILLY. p. 156. ISBN 978-0-596-00712-6. Retrieved 2012-09-12.&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Abstract_factory_UML.png&amp;diff=70668</id>
		<title>File:Abstract factory UML.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Abstract_factory_UML.png&amp;diff=70668"/>
		<updated>2012-11-19T20:11:05Z</updated>

		<summary type="html">&lt;p&gt;Ssivaku4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ssivaku4</name></author>
	</entry>
</feed>