Skip to main content

Re: Proposal

  • From: Werner Keil < >
  • To: " " < >
  • Subject: Re: Proposal
  • Date: Sun, 2 Nov 2014 16:01:38 +0100

Still of() is a name for static factories, like valueOf() used to be, so
we'd violate common sense and naming that became fairly used in recent JSRs
(including the  platform)

At most a concrete implementation like
https://github.com/unitsofmeasurement/unit-api/blob/master/src/test/java/javax/measure/test/quantity/TestQuantityFactory.java
with a method like
public static <Q extends Quantity<Q>> QuantityFactory<Q> getInstance(final
Class<Q> type) {
if you really insist could be renamed to of().

getInstance() and of() are used fairly well defined next to each other  in
CLDC 8 or MEEP 8.
If you get a distinct SINGLETON, even say per quantity type, then that's
where the current getInstance(Class<Q> type) method is right.
If the result is not guaranteed to be a singleton, then of() covers pretty
much all other cases.

It would be bad choice to mix them, but calling the non static method in
QuantityFactory of() would be unacceptable.
We have to wait till ME gets Lambdas, until then a concrete implementation
does the same job well.
And the method that gets the Q or Quantity<Q> for a factory should be named
create() for a Builder (the lines are often blurred, see JSR 354) it would
be build() if a name change here had so many fans?[?]


 Werner
On Sun, Nov 2, 2014 at 3:35 PM, Martin Desruisseaux <
>
 wrote:

>  Le 02/11/14 21:02, Jean-Marie Dautelle a écrit :
>
> We could also define QuantityFactory as:
>
>  interface QuantityFactory<Q extends Quantity<Q>, N extends Number> {
>      Q of(N value, Unit<Q>);
> }
>
>
> So you propose one factory instance per quantity type? Why not a single
> factory for all types?
>
>     Martin
>
>

Attachment: 35F.gif
Description: GIF image



Re: Proposal

(continued)

Re: Proposal

Jean-Marie Dautelle 11/02/2014

Re: Proposal

Werner Keil 11/02/2014

Re: Proposal

Werner Keil 11/02/2014

Re: Proposal

Jean-Marie Dautelle 11/02/2014

Re: Proposal

Werner Keil 11/02/2014

Re: Proposal

Jean-Marie Dautelle 11/02/2014

Re: Proposal

Jean-Marie Dautelle 11/02/2014

Re: Proposal

Werner Keil 11/02/2014

Re: Proposal

Jean-Marie Dautelle 11/02/2014

Re: Proposal

Martin Desruisseaux 11/02/2014

Re: Proposal

Werner Keil 11/02/2014

Re: Proposal

Jean-Marie Dautelle 11/02/2014

Re: Proposal

Jean-Marie Dautelle 11/02/2014

Re: Proposal

Werner Keil 11/02/2014

Re: Proposal

Jean-Marie Dautelle 11/02/2014

Re: Proposal

Otávio Gonçalves de Santana 11/02/2014

Re: Proposal

Werner Keil 11/02/2014

Re: Proposal

Otávio Gonçalves de Santana 11/03/2014

Re: Proposal

Otávio Gonçalves de Santana 11/03/2014

Re: Proposal

Martin Desruisseaux 11/03/2014

Re: Proposal

Martin Desruisseaux 11/03/2014
 
 
Close
loading
Please Confirm
Close