Range API
Alan Snyder
javalists at cbfiddle.com
Tue Sep 24 14:11:10 UTC 2024
I have another example: I have a datatype that represents a region of an audio track, for example, one tune in a medley of tunes. I allow the region to
specify both a start and end time, but the end time is optional (and mostly not used). When the end time is not specified, the region ends at the start of the next region, or at
the end of the track if there is no next region. The latter case is useful because the exact track length may not be known. The optionality of the end time
is not represented in the type system.
Having said that, I’m not sure that a general abstract interface would be useful for this example.
> On Sep 24, 2024, at 2:13 AM, Olexandr Rotan <rotanolexandr842 at gmail.com> wrote:
>
> As part of the redesigning process , I am researching whether or not there are use cases that require asserting that the range is exactly half-bounded. This is important because I plan to switch to BoundedAtEnd/BoundedAtStart sealed interfaces instead of flags and runtime checks: Here is what I gathered for now.
>
> Date/Time Handling (Historical or Forecast Data): When dealing with events that started at a specific time but have no known end (e.g., open-ended employment contracts or ongoing subscriptions)
> Stream Processing (Real-time Event Streams): In real-time systems, you might process data that has a start time but no defined end, such as monitoring a live video feed or logging system. The range is bounded at the start and unbounded at the end as more data will continuously arrive.
> Data Pagination (Fetch Until Condition): When implementing pagination, sometimes you might want to fetch items starting from a specific index up to an unbounded limit (e.g., fetching all items after a certain point until memory runs out or a condition is met).
> Auditing and Monitoring: In systems where audit trails or logging data should capture all events after a certain point (bounded start) with no foreseeable end (unbounded end), such as monitoring changes to records in a database starting from a fixed timestamp.
> Scientific or Statistical Ranges: When modeling physical systems or statistical ranges, you might want to capture measurements that begin at a known threshold but theoretically have no upper or lower bound. For example, recording temperature data starting at absolute zero and increasing without any known upper limit.
> Inventory or Resource Allocation: Resource allocation policies, such as those for virtual machines, may be based on known minimum allocation thresholds but have flexible or unbounded resource caps, depending on availability.
>
> I am writing to ask whether anyone who worked with such systems could confirm/deny that those are real use cases. If so, would it be satisfying enough to assert one-way unboundness with instanceof checks, i.e. range instanceof UnboundedEndRange && !(range instanceof UnboundedStartRange). Would appreciate any feedback.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20240924/d8dbb9b8/attachment.htm>
More information about the core-libs-dev
mailing list