Jump to content

Talk:Factory (object-oriented programming)

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
[edit]

In the phrase "concrete type", the word 'concrete' has been wikified, but this links it to the page concrete, which is hardly appropriate. It's not quite clear what article it should link to; the nearest I can come up with is Abstraction_(computer_science), which unfortunately doesn't mention the antonym 'concrete' until the 'Considerations' section. For now, I've pointed it at the disambiguation page. 131.111.202.32 (talk) 11:44, 18 January 2011 (UTC)[reply]

The text of this article almost completely overlaps part of the text in the article factory method pattern, to which this concept is closely related. There is no point in keeping identical copies of text in two separate places. JIP | Talk 19:28, 16 August 2011 (UTC)[reply]

That's not true. Factory method pattern is a method to create factories in object oriented languages. You cannot apply such a pattern in non-object-oriented languages such as C. Nevertheless, you can implement a factory in C using dynamic memory. The theoretical concept and the pattern should be kept appart
--Juansempere (talk) 16:21, 27 August 2011 (UTC)[reply]

Since the merge has already taken place (all of the text in this article is also at the longer article factory method pattern) and there has been no discussion since several months ago, I decided to be bold and redirect this page to factory method pattern. My edit was reverted. If indeed the theoretical concept and the pattern should be kept apart, then this page needs to be completely rewritten–if it doesn't say something that isn't duplicated elsewhere, then the goal of separating the two ideas isn't achieved at all. So, is someone prepared to rewrite this page? or should we go ahead and redirect? Jowa fan (talk) 02:08, 19 December 2011 (UTC)[reply]

Since noone has replied, I'm going to redirect the page again. If anyone disagrees with this, please give a clear explanation here. Jowa fan (talk) 04:16, 4 January 2012 (UTC)[reply]
  • oppose There are two factory patterns (as described in GoF). This isn't widely appreciated: "factory" is one of the best known of them, but the dual nature of its description isn't. Accordingly there is value to having a single overall article that sits in the namespace at Factory (design pattern) and can then lead on to the other two articles, each of which has to closely follow the scope of its sourcing from GoF. Andy Dingley (talk) 10:41, 4 January 2012 (UTC)[reply]
  • support I support a merge. The point that the difference between the two patterns is not widely appreciated is probably true. It would therefore be more useful to cover both variants (if really necessary) in the same article so that the differences can be better explained.
Also, this page's usefulness is questionable since most effort and discussion happens at the other page. — Preceding unsigned comment added by Mbartz (talkcontribs) 02:22, 5 December 2013 (UTC)[reply]

The concept of factory, factory method, and factory method pattern are explicitly distinguished in the OO literature. These are related concepts, particularly in C++ and Java, but completely different in other languages, such as Python (a factory is a basic concept in Python, and involves neither an explicit method call nor the factory method pattern). I’ve given various references to different terminology in Factory (object-oriented programming)#Terminology as of this version. The articles need further work to distinguish these, but I’m closing the merge since these are clearly separate, as many sources and editors have stated.

—Nils von Barth (nbarth) (talk) 07:18, 30 March 2014 (UTC)[reply]

Incorrect code of function

[edit]

Functions don't have attributes (at least in Python). So, f.obj is incorrect here.

def f():
    if f.obj is None:
        f.obj = A()
    return f.obj

PS: I don't know singleton pattern so can't edit the implementation.Antchal (talk) 09:06, 29 June 2021 (UTC)[reply]