fundamental design issues with trips and dives

Linus Torvalds torvalds at linux-foundation.org
Thu Nov 7 10:03:48 PST 2019


On Thu, Nov 7, 2019 at 9:46 AM Dirk Hohndel <dirk at hohndel.org> wrote:
>
> I like the thinking here. Radically simple. It does, however, breaks a lot of assumptions in our code, but I'm willing to deal with that in favor of something that's logical and consistent.

Hmm. It shouldn't break any assumptions in any of the original code,
because that was very much the original design of a trip. A trip is
just a collection of dives.

A trip itself has a date, and that is then used for sorting trips vs
other trips, but the trip date is actually just the date of the first
dive in the trip.

So changing the time of a dive can affect the *sorting* of trips, but
should have no other effect.

> We keep the dive_table.dives[] array sorted by date. Is that a mistake?

No, I think you should just consider the dives always sorted by date.
But a trip is not a _range_ of dives, it's just a collection of said
dives.

So dives are sorted in the trip too, but two trips can have completely
overlapping dives.

I know this actually used to work, because we tested it. You can
remove a dive from the middle of a trip, and it just works. It's
"outside" the trip, even if it's inside the range of dates of dives
that are inside a trip.

Of course, the fact that this all used to work fine doesn't mean that
it still does.

[ Goes off and tests ]

Sure it does.

At least on desktop. You can happily do this:

 - remove a dive from the middle of a trip

 - select that dive and do "create new trip above"

and what you get are two trips that are correctly sorted by the date
of their first dive, even though the times are overlapping.

And I've used this several times on purpose. It's one reason why we
have "download into new trip" when downloading from a dive computer.
I've used that to make sure we don't merge dives when I had lent my
dive computer to another person, because the trip thing means that it
keeps the dives away from previous dives too.

So the whole "trip is just a collection of dives independently of
dates" is important, and has actually been the design all along. You
seem to just not have been aware of that  ;)

            Linus


More information about the subsurface mailing list