commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gilles <gil...@harfang.homelinux.org>
Subject [Numbers] API of "Complex"
Date Thu, 01 Feb 2018 12:59:13 GMT
Hi.

IMHO, there are too many accessor and factory methods.
We should strive for a lean and consistent API.

For the factory methods, I suggest the "of" convention:
  public static Complex ofCartesian(double re, double im)
  public static Complex ofPolar(double abs, double arg)
And, as syntactic sugar:
  public static Complex ofCis(double arg)

For the accessors:
  public double re() { return real }
  public double im() { return imaginary }

I'd have
   public double arg()
   public double abs()
in order to compute the polar coordinates.

I'm -0 to have others as syntactic sugar since they are
misleading (a.o. when "implying" the read of a field when
a computation is performed).

WDYT?

Regards,
Gilles


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message