|
Authored by: mschmitz on Monday, April 23 2012 @ 04:26 PM EDT |
The judge explicitly asks about inheritance here. From that point of view,
grouping related things together (here maths) is pretty much mandatory as long
as you wish to retain a reasonably coarse-grained API. The cosine function can
inherit types from the math class, and its implementation will likely derive
from common algorithms used for other trig functions.
Anything that is just implements maths can go in the same class. Anything that
just uses maths inherits from it (your XML class). If you want to prevent XML to
pull in cosine code, or put cosine in with another class, you'd have to put all
the types in a separate class. Only then would that hypothetical class _not_
depend on the math class because of the required types (and possibly private
methods for the algorithm). True Java heads please correct me if I'm wring
here.
(I don't think inheritance of some class from math just for the purpose of a
single function is much of a problem in practice, once the references have been
resolved and the bytecode is loaded. The question appears to be conceptual in
nature - the judge has come to the conclusion that certain groupings of
functions the way they are specified have to be done just so for a sound
technical reason, not 'creative expression', and is looking for confirmation.)
-- mschmitz
[ Reply to This | Parent | # ]
|
|
Authored by: Oliver on Monday, April 23 2012 @ 04:35 PM EDT |
The main efficiency of the "Correct" grouping is a reduction
in dependencies between packages. A tree structure is better
than a graph, i.e. all dependencies flow in one direction so
that there is one package that depends on no others.[ Reply to This | Parent | # ]
|
|
|
|
|