Weeknotes 2021 Week 10

Weeknotes 2021 Week 10

Experimenting with Moya (Swift)

Or Should I take on this dependency?

Working on the macOS client for Button. Looking at the networking layer.

Previously came across a reference to a package called Moya which lets you define a type-safe wrapper around your API calls. You define a service, with operations, with known parameters, something like:

enum MyService {
    case zen
    case showUser(id: Int)
    case createUser(firstName: String, lastName: String)
    case updateUser(id: Int, firstName: String, lastName: String)
    case showAccounts
}

Then you use those operations, rather than manipulating URL strings, query parameters, and all the rest of it to build our HTTP requests.

At the initial pass it’s nice. It’s a good example of where strong typing pays. You get autocomplete, which is the most important thing obviously. The compiler tells you what’s wrong with your code. And consequently, bar parameter values, there’s no chance that you configured your request wrong. (It’s also a great example of how badly Python enums lack associated values, but that’s another story…)

But it looks like Moya is currently unmaintained. Ah, there’s the rub…

So, more interesting that Moya itself is, what do you do when you find a library that does what you want but isn’t actively maintained? Do you take it on or pass?

Here’s my test: if push comes to shove, can I fix this myself? If not, then pass is favourite.

I’ve seen too many Django projects stuck on an end-of-life Django because they’d pulled in some third-party app that wasn’t compatible with the new version to take on dependencies lightly.

The solution is to fix the dependency, get it updated, and get back onto a supported version of Django.

Not being able to contribute back to your dependencies is a form of technical debt.

So, before you take on a dependency, answer, can I help to support this?

With Moya, I’m not sure what my answer is. PRs don’t look to be being handled at all, so it’s not just, can I help? but can I handle my own fork?

The core itself looks pretty small — but more than I want to rewrite myself — that’s the plus. There are extensions for ReactiveSwift and RxSwift, as well as various packaging options, which I could just delete… — that’s the maybe. 🧐

But I’m not sure yet. Thinking on it — I’ll play a bit more, and make sure I fully grok those internals before I decide.

Either way, I’ll do something in this area, as the resultant API is very nice indeed.

Things to listen to, read and watch in French

My French up to now has been what I’d call supermarket level. We visit France regularly enough; I can see the Pyrenees from my house. My Catalan and Spanish are (will forever be) firmly in the ongoing life-project category now. So, time to up the stakes.

I’ve committed to 15-30mins every day in the evening. Up to 19 days now. I suspect that the whole 21 days to make a habit thing is BS, but I’m stubborn, so we’re off.

The thing that I found really changed the game for me with Spanish and Catalan was reading, followed by listening to music and watching films.

So, I put out a request on Twitter:

J'apprends le françaisFlag of France Pouvez-vous recommander de la musique, des livres et des films. Merci beaucoup.

Initial pass we seem to be a little low on books but, here are the lists.

Thanks to everyone who replied. Do add more if you have suggestions!

Film

  • Intouchables (2011)
  • Persepolis (2007)
  • Les Choristes (2004)
  • Astérix et Obelix : Mission Cléopâtre (2002)
  • Le Fabuleux Destin d’Amelie Poulain (2001)
  • Le Dîner de Cons (1998) (Recommended twice)
  • Dix pour cent (TV, Netflix)
  • Le Grand Restaurant (1966)
  • Cuisine américaine (1988)

Livre :

  • Tout savoir sur le vin
  • Les fourmis de Bernard Werber

Musique :

  • Polnareff
  • Nowlenn Leroy
  • Grand corps malade
  • Georges Brassens
  • Léo Ferré
  • Les ogres de Barback
  • Debout sur le zinc
  • Les Hurlements de Léo
  • Les Wriggles
  • Oldelaf & Monsieur D
  • les Fatals Picards
  • Bobby Lapointe
  • Jacques Brel
  • Jean-Jacques Goldman