MVVM Is Quite Okay at What It Is Supposed to Do

Criticism targeting MVVM (Model–View–View-Model) from late last year essentially points out it's not the silver bullet some take it for.[^delay] Most of the stuff is missing the point. How are you supposed to make sense of it? What's good advice for your project? I want to raise awareness about the underlying issues that often go undiscussed: the use and limits of patterns like MVVM, and understanding the problems you try to solve with it.

Continue reading …

Location Matters

The location of a piece of code always matters. I was fiddling with the Charts library today and found out that if you set a chart's data to nil, it renders some informative text by default. My data source doesn't pass nil but an empty array around, though, so I had to convert empty arrays to nil to make use of this feature.

Continue reading …

Extract Private Functions as Collaborators

"Using a private function means having a hardwired link to an anonymous collaborator. Over time, this will slowly hurt more." (@jbrains) I was thinking about this the other day when I wrote tests for a presenter. It receives a date, formats it, and makes the view update a label with the result. Simple. (The real thing actually does a bit more, but that doesn't matter much.)

Continue reading …

Separating State from State Changes

Reflecting on a recent change of the Word Counter's file monitoring module, I think I re-discovered a commonly advised pattern in my code: to separate state from state changes. There's an object that knows how to handle files based on extension: plain text files's words are counted differently than Word or Scrivener files. Call it Registry. Previously, this was set up once and didn't change. Now I wanted to make this configurable so users can add custom plain text extensions. This means changing that object's state.

Continue reading …