Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #30589

Re: a question about factory method

From Roedy Green <see_website@mindprod.com.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: a question about factory method
Date 2014-12-18 13:43 -0800
Organization Canadian Mind Products
Message-ID <7fi69ah7v8pgb7h80d99osufk9k3m1sgce@4ax.com> (permalink)
References <ff7f0941-582f-4a6f-83fd-2fa71434ff46@googlegroups.com>

Show all headers | View raw


On Thu, 18 Dec 2014 05:57:30 -0800 (PST), John <xsli2@yahoo.com>
wrote, quoted or indirectly quoted someone who said :

>Could you explain to me why their code is better than mine?

You normally would not bother with a static factory. You use a factory
when you want do create different kinds of object based on the
parameters, or when you think you might in future.  You could convert
to a more complex algorithm without modifying the calls to the
constructor.


Your static constructor for example might look for some magic pairs of
real/imag and return constants instead of creating a new object
-- 
Roedy Green Canadian Mind Products http://mindprod.com
Software is a gas; it expands to fill its container.
~ Nathan Myhrvold (born: 1959-08-03 age: 55) Nathan’s First Law

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

a question about factory method John <xsli2@yahoo.com> - 2014-12-18 05:57 -0800
  Re: a question about factory method Robert Klemme <shortcutter@googlemail.com> - 2014-12-18 15:28 +0100
  Re: a question about factory method Silvio <silvio@internet.com> - 2014-12-18 15:43 +0100
  Re: a question about factory method Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-12-18 10:37 -0500
    Re: a question about factory method John <xsli2@yahoo.com> - 2014-12-18 08:04 -0800
      Re: a question about factory method Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-12-18 12:04 -0500
        Re: a question about factory method John <xsli2@yahoo.com> - 2014-12-18 10:43 -0800
          Re: a question about factory method Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-12-18 14:24 -0500
            Re: a question about factory method Robert Klemme <shortcutter@googlemail.com> - 2014-12-19 01:39 +0100
  Re: a question about factory method Roedy Green <see_website@mindprod.com.invalid> - 2014-12-18 13:43 -0800

csiph-web