Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Recall that the Factory Pattern is used to create object without specifying the exact class of the object, thus decreasing the coupling between those two components. The Abstract Factory Pattern even decreases the amount of de-coupling by defining an interface which all factories must implement. Thus the caller of the abstract factory doesn't know anything about the implementation of factory and how objects are created. The caller just nows, calling a method on the factory will yield a certain object instance of interface X. </p> <p>The XML Library example from Matt is actually a good example. The abstract factory is the entity creating the XML parser which creates a <code>Document</code> object representing the actual document you parse. Actually, for you as a caller, it is most of the time completely irrelevant which Parser is used, as long as you get a <code>Document</code> object out of it. Therefore you can simply use the abstract factory. Which creates you a valid parser (most of the times ;))</p> <p>The Toolkit example (also mentioned by Matt) is a more school-book like example. Imagine you just want to populate a window on the user screen. As you want to do it in a platform independent way, you define an abstract class Window with which you can do certain operations. Then you create an object which creates these windows, let's say <code>Win32WindowsFactory</code>. However, as your code shall be platform-independet, you define an interface <code>WindowsFactory</code> which provides you a method <code>createWindow()</code>. When the <code>Win32WindowsFactory</code> is used, a <code>Win32Window</code> is returned, when a <code>LinuxGTKWindowsFactory</code> is used, a <code>GTKWindow</code> is returned. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload