Talk:Abstract factory pattern

message: The "Alternative implementation" Python example does not implement the abstract factory pattern.  — Preceding unsigned comment added by 45.72.223.70 (talk) 20:41, 24 February 2023 (UTC)
replies: text: It seems you are right: it's some traditional factory.  That's one reason more to delete it. One code sample is sufficient. Adding all possible variations does not provide added value ( MOS:CODE supports this point of view, see also this other section).  If moreover the alternate implementation creates some confusions, it shall be deleted. Christophe (talk) 13:38, 25 February 2023 (UTC)
thread_title: Alternative implementation?

message: Merged the C# and C++ examples in one section. Mostapha
I know, a UML diagram is not everything, but I think it would help here to understand the pattern. If this is ok, I'll try to add one soon. --Bjoern.thalheim 09:38, 25 October 2005 (UTC)
thread_title: Problems with code examples and UML diagram

message: Hello, i took the liberty of adding a Java code sample of the AbstractFactory example. It is very similar to the C# example, other than minor differences in language construct such as :/extends, public getters/setters etc. -- [Richard]
Hello, Richard. Your Java code does not compile. In order to get the name of the OS, you do something like
      String name = System.getProperty("os.name");
Therefore, in order for the createOsSpecificFactory() method to work you need
  public static GUIFactory createOsSpecificFactory() {
    String os = System.getProperty("os.name");
    /* we're not interested in which version of Windows it is,
       so we only look at the first three letters */
    if ( os.substring(0,3).equalsIgnoreCase("win") )
      return new WinFactory();
    else
      return new OSXFactory();
  }
Regards,
Mihai
Hi, 
'var' is not a Java keyword. So this is not correct. 
Greets, 
Bart.  — Preceding unsigned comment added by 82.94.187.71 (talk) 14:49, 19 August 2019 (UTC)
thread_title:  JAVA Code Sample 

message: Someone should remove the autoptr - it confuses a reader inregards to the actual point of the article.
JoshHolloway 17:44, 20 December 2006 (UTC)
thread_title:  Comment on behalf of 12.160.193.229 

message: How come other language examples have been removed. They looked useful to me. There was no discussion here. Any reason? peterl 10:58, 5 March 2007 (UTC)
replies: text: There are about 200 different languages listed in http://en.wikibooks.org/wiki/List_of_hello_world_programs . Where would you like the line be drawn? In my opinion even the current examples are too much. If an example is given, it should be given in pseudo code. —The preceding unsigned comment was added by 194.29.198.121 (talk) 12:30, 12 March 2007 (UTC)
replies: text: Of course not 200. But more than one. Patterns like this are only relevant if the language has good support for modern OO principles. Personally, I'd choose C++ or C#  or Java (my preference), maybe Perl or Python. I'm guessing Visual Prolog shows the techniques well, although it's not a language I'm familiar with. peterl 04:04, 13 March 2007 (UTC)

text: Wikipedia is not a specialized programming manual, I suggest that people buy a manual for their language of choice. I have removed again the extra examples. (Python and PHP this time). --Enric Naval (talk) 17:19, 31 January 2010 (UTC)

text: I removed extra example again (this time C# and two examples in Python). There are code examples linked from the external links section. --Enric Naval (talk) 20:52, 28 November 2010 (UTC)
replies: text: I think, on the contrary, that good examples written in widely used languages implementing OO programmation (such as Java, C# and C++) are very much useful. Abstract principles is good but concrete examples make them much more easy to understand !  Ptyxs (talk) 13:12, 14 November 2011 (UTC)
thread_title:  Removal of other language examples 

message: The C++ example is wrong. Maybe not the factory pattern itself, but it contains really bad code which misses several deletes, plus the last line ("delete x, y;") will only delete one of x and y.
See following demonstration:
 #include <iostream>
 struct Foo {
     Foo ()  { ::std::cout << "Foo::Foo(), this = "  << this << '\n'; }
     ~Foo () { ::std::cout << "Foo::~Foo(), this = " << this << '\n'; }
 };
 int main () {
     Foo* a = new Foo();
     Foo* b = new Foo();
     delete a, b;
 }
Output:
 Foo::Foo(), this = 0x929a008
 Foo::Foo(), this = 0x929a018
 Foo::~Foo(), this = 0x929a008
Whoever wrote that example should hand over his c++ coding license.
Phresnel (talk) 12:39, 11 January 2009 (UTC)
thread_title:  C++ example code is wrong. 

message: I would like to share the following UML diagrams I have published on Design Patterns Open Online Learning. Your comments are welcomed!
In the above UML class diagram, 
the Client class that requires ProductA and ProductB objects doesn't instantiate the ProductA1 and ProductB1 classes directly.
Instead, the Client refers to the AbstractFactory interface for creating objects,
which makes the Client independent of how the objects are created (which concrete classes are instantiated).
The Factory1 class implements the AbstractFactory interface by instantiating the ProductA1 and ProductB1 classes.
The UML sequence diagram shows the run-time interactions: 
The Client object calls createProductA() on the Factory1 object, which creates and returns a ProductA1 object.
Thereafter, 
the Client calls createProductB() on Factory1, which creates and returns a ProductB1 object. 
Vanderjoe (talk) 17:05, 15 July 2017 (UTC)
thread_title:  UML class and sequence diagram 

message: This article is historically grown and provides lots of useful content.  However, it seems that some cleaning actions are required, or it will soon be very difficult to read and maintain: 
* DONE: The introduction must be shortened to 1 or max 2 paragraphs and must be kept general.  Detailed explanation must be moved elsewhere in the article.  See also Wikipedia:WikiProject Computer science/Manual of style.
* DONE: Remove redundant class diagrams.  The article currently contains 3 class diagrams.  This redundancy (sometimes with different names) risk to confuse the readers. One class diagram and one sequence diagram should be sufficient. One diagram was wrong and was reverted to a previous correct version. 
* TODO: Remove the alternative python code.  One code sample is sufficient.  Adding all possible variations does not provide added value.  Wikipedia is not a source code library: see MOS:CODE in case of doubt. -- Moreover, it seems according to this section that the alternate example is misleading. 
* DONE: Remove LEPUS3 chart section.  There is no source for this chart (link broken, no relevant content found in wayback machine). The graphical formalism of LEPUS3 is not widely known, which makes this diagram of little use in an Encyclopaedia.  
* DONE: cross-check external links - several seem broken.  Moreover, Wikipedia is not meant to be an advertising place for third party website. The criteria regarding reliability, and independence must be cross-checked as well, according to Wikipedia:Independent_sources#Policies_and_guidelines_requiring_third-party_sources.
* DONE: describe the two main variants of this pattern, i.e. abstract class based (original GoF, written at a time where only rare languages provided native support for interfaces) and interface based.   — Preceding unsigned comment added by Cth027 (talk • contribs) 20:29, 24 February 2023 (UTC)
thread_title:  Time for some cleaning?