Hey #rustlang fans I have an “architecture” question. I’m making a browser for the #gemini protocol. I’m trying to add #gopher support. The first step was to duplicate everything but then as you can guess that’s not great.
The starting point point is an URL and depending on the scheme I go one way or the other. The path is the same: get content, parse it, display it to the user.
What would be a great way to architecture this duplication?
@julienxx Kelly copy and paste and have the code twice. :D
@tomasino well that works but I feel I can do better 😅 or at least learn something in the process
@julienxx you can probably do URL parsing in a shared bit, and maybe some "render to screen" stuff, but otherwise the logic is going to diverge. I'd honestly worry about conflating the two by trying to force them to share logic or even implementation patterns. Gemini is still in flux and it may take a right turn from Gopher at any moment. You could do worse than carving them in half.
@tomasino yes the logic is diverging but not so much since in both cases I’m doing stuff line by line. It’s tempting to merge a Gemini input with a Gopher type 7 for example but I think you’re right. The UI stuff is already agnostic so should be the specificities of each protocol. My real issue is checking for the scheme too many times
"I appreciate SDF but it's a general-purpose server and the name doesn't make it obvious that it's about art." - Eugen Rochko