Skip to main content

Re: On Quantity - Measurement relationship

  • From: Martin Desruisseaux < >
  • To:
  • Subject: Re: On Quantity - Measurement relationship
  • Date: Sun, 02 Nov 2014 00:12:14 +0900
  • Organization: Geomatys

<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>There is a fourth option:<br>
    </p>
    <p>4. Keep the current hierarchy by defining JSR-363's <tt>Quantity</tt>
      as a <i>quantitative measurement</i> (or a physical quantity).
      However names could be changed if that help.<br>
    </p>
    <p>Option 2 has the following consequences:<br>
    </p>
    <h4>Questionable use of "measurement" word</h4>
    <p><tt>Measurement</tt> extends <tt>Quantity</tt> imply that a
      measurement is always a scalar, which I question. To me, a vector
      is also a measurement, which implies that <tt>Measurement</tt>
      can not extends <tt>Quantity</tt>. However the second name
      proposal (<tt>Amount</tt>) seems to work.<br>
    </p>
    <h4>Weaker constraint on parameterized type<br>
    </h4>
    <p>If <tt>Quantity</tt> is the base interface instead than the
      subtype, then <tt>Unit&lt;Q extends Quantity&lt;Q&gt;&gt;</tt> or
      any other object parameterized with <tt>Quantity</tt> would
      accept types that do not make much sense. For example in addition
      to <tt>Unit&lt;Length&gt;</tt> and <tt>Unit&lt;Mass&gt;</tt>,
      such hierarchy would also accept <tt>Unit&lt;Measurement&gt;</tt>.
      If we want to prevent such thing, then the <tt>Quantity</tt>
      interface (or whatever we name it) must be a subtype of <tt>Measurement</tt>
      (or whatever we name it).<br>
    </p>
    <h4>Mass, Length and other Quantity subtypes become less useful<br>
    </h4>
    <p>Since <tt>Quantity</tt> would be an empty interface, <tt>Mass</tt>,
      <tt>Length</tt> and other <tt>Quantity</tt> sub-types become
      nothing more than marker interfaces, which make them less useful.
      With the current hierarchy, it is possible to write:<br>
    </p>
    <blockquote>
      <pre>Mass mass = myObject.getMass();
</pre>
    </blockquote>
    <p>I also argue that we can write the following type-safe expression
      (Werner said that it doesn't work, but from my understanding he
      tried to implement that by using reflection on the parameterized
      type, which is indeed of limited use in current Java. I was
      thinking more about the <tt>Unit&lt;Q&gt;</tt> implementation
      having a <tt>Class&lt;Q&gt;</tt> internal field containing the
      necessary information):<br>
    </p>
    <blockquote>
      <pre>Mass mass = (Mass) a.multiply(b);
</pre>
    </blockquote>
    <p>But with option 2, it is no longer possible. We would have no
      other choice than writing:<br>
    </p>
    <blockquote>
      <pre>Measurement&lt;Mass&gt; mass = myObject.getMass();
</pre>
    </blockquote>
    <p>and the above type-safe cast is no longer possible - a <tt>Measurement.asType(Class&lt;Q&gt;)</tt>
      method become the only alternative I can see.<br>
    </p>
    <p><br>
          Martin<br>
      <br>
    </p>
    <br>
    <div class="moz-cite-prefix">Le 01/11/14 22:53, Jean-Marie Dautelle
      a écrit :<br>
    </div>
    <blockquote
cite="mid:CABygTfgG5qdqEZnTqGhJjEhmYZwSsQE=Hr42gLERX3r4Yyy=
      "
      type="cite">
      <div dir="ltr">Hi All,
        <div><br>
        </div>
        <div>Here are the different options, I think:</div>
        <div><br>
        </div>
        <div>1. Quantity and Measurement are merged into a single
          Quantity abstraction having a value (number) and a unit (and
          there is no Measurement abstraction) </div>
        <div><br>
        </div>
        <div>2. Measure(ment)/Amount extends a high level Quantity
          abstraction (which allows for very abstract  quantities,  even
          enum, e.g. Mass m = HEAVY, no value and no unit). Note: We see
          in that case that Quantity cannot implement Comparable.
          HEAVY/LIGHT may depend on the context, the boundary may not be
          well defined or be relative, e.g. we can compare HEAVY with
          LIGHT but not HEAVY with another mass).</div>
        <div><br>
        </div>
        <div>3. Quantity and Measure(ment) have distinct hierarchies. A
          Measure(ment) is not a quantity but a numerical/scalar
          representation of it (the same way that the image of an
          Elephant is not an Elephant).</div>
        <div><br>
        </div>
        <div>All options are valid and the choice is yours  <img
            src="cid:part1.07000701.07040502@geomatys.fr" goomoji="361"
            style="margin: 0px 0.2ex; vertical-align: middle;"> !</div>
        <div><br>
        </div>
        <div>My personal favor goes for 2  </div>
        <div><br>
        </div>
        <div>Cheers,</div>
        <div>JM<br>
        </div>
      </div>
    </blockquote>
    <br>
    <br>
  </body>
</html>

Attachment: gifIYypB8M3Hu.gif
Description: GIF image



On Quantity - Measurement relationship

Martin Desruisseaux 11/01/2014

Re: On Quantity - Measurement relationship

Jean-Marie Dautelle 11/01/2014

Re: On Quantity - Measurement relationship

Martin Desruisseaux 11/01/2014

Re: On Quantity - Measurement relationship

Werner Keil 11/01/2014

Re: On Quantity - Measurement relationship

Jean-Marie Dautelle 11/01/2014

Re: On Quantity - Measurement relationship

Werner Keil 11/01/2014

Re: On Quantity - Measurement relationship

Jean-Marie Dautelle 11/01/2014

Re: On Quantity - Measurement relationship

Martin Desruisseaux 11/01/2014

Re: On Quantity - Measurement relationship

Werner Keil 11/01/2014

Re: On Quantity - Measurement relationship

Martin Desruisseaux 11/01/2014

Re: On Quantity - Measurement relationship

Werner Keil 11/01/2014

Re: On Quantity - Measurement relationship

Martin Desruisseaux 11/01/2014

Re: On Quantity - Measurement relationship

Werner Keil 11/01/2014

Re: On Quantity - Measurement relationship

Martin Desruisseaux 11/01/2014

Re: On Quantity - Measurement relationship

Werner Keil 11/01/2014

Re: On Quantity - Measurement relationship

Martin Desruisseaux 11/01/2014

Re: On Quantity - Measurement relationship

Werner Keil 11/01/2014

Re: On Quantity - Measurement relationship

Jean-Marie Dautelle 11/01/2014
 
 
Close
loading
Please Confirm
Close