Hi.

Looking at some way out for MATH-1228, I uncovered what looks to me
as an abuse of inheritance: "ThirdMoment" extends "SecondMoment".

"Skewness" contains a "ThirdMoment" instance variable but, in order
to compute its value, "m3" (cf. "getResult()"), it also must read
the result of that variable's parent type ("SecondMoment"), i.e. "m2".

IMO, this makes no sense at the conceptual level: a third moment is
_not_ a second moment.

And the problem is compounded as:
 * "FourthMoment" inherits from "ThirdMoment", and
 * "SecondMoment" extends "FirstMoment".

In this strange hierarchy, the fields are all "protected" in order
to be accessed from subclasses, making the whole thing fragile and
inefficient (as pointed out by the OP of MATH-1228).

From a programming POV, the design is flawed because "getResult()"
is, rightfully, intended to be overridden in subclasses.
However, "protected" access is used to work around that very purpose
of inheritance.
And thus, good practice (cf. MATH-758) cannot be implemented.

Did I miss the point of this package's design?
Or am I right that it should be completely redesigned?


Regards,
Gilles


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

Reply via email to