You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@mesos.apache.org by "Benjamin Bannier (JIRA)" <ji...@apache.org> on 2016/07/03 15:10:11 UTC

[jira] [Created] (MESOS-5773) Bytes and Duration subclasses subvert the type system

Benjamin Bannier created MESOS-5773:
---------------------------------------

             Summary: Bytes and Duration subclasses subvert the type system
                 Key: MESOS-5773
                 URL: https://issues.apache.org/jira/browse/MESOS-5773
             Project: Mesos
          Issue Type: Bug
            Reporter: Benjamin Bannier
            Priority: Minor


{{Bytes}} and {{Duration}} have a number of subclasses to create quantities with different units, i.e.,
* {{Bytes}} is specialized as {{Gigabytes}}, {{Kilobytes}}, {{Megabytes}}, and {{Terabytes}}, and
* {{Duration}} is specialized as {{Days}}, {{Hours}}, {{Microseconds}}, {{Milliseconds}}, {{Minutes}}, {{Nanoseconds}}, {{Seconds}}, and {{Weeks}}.

Effectively all these subclasses do is add multiplicative factors to the wrapped value. The subclasses are often used interchangeably with their base class, often involving slicing away type information (which is technically safe as the subclasses do not contain additional members or functions).

These type hierarchies seem to needlessly complicate the type system. It becomes e.g., much harder to catch all {{Duration}} types when specializing templates. It seems that e.g., a factory function {{Seconds}} directly returning a {{Duration}} would work just as well, but keep the type system cleaner.




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)