141 days ago · 8 min read1555 words · Tech · hide · Fediverse post

I want to tell you a story about a problem I spent an embarrassingly long time debugging.The project I'm working on now is by far the most technically ambitious thing I've ever built myself. I have contributed to more technically ambitious problems, but I've never been the primary developer, or had to make as many foundational design decisions.One of the most complicated parts of the project has been managing ordered lists. It allows multiple clients to connect to a particular list and make ordering changes. It uses Sortable.js to manage changes to the order on the client, and then a Phoenix LiveView to persist those changes to other clients, and store them off in a database. I'm now on my third design for the "store in the database" part, and it took me over a year to get here.The Naive ApproachI started out implementing this with what seemed like a simple, straightforward implementation: Each item in the list gets a "position" field, and that position is an integer. The "move"…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town