Coding 2021-07-21

By Max Woerner Chase

I did a bunch of cleanup of the code today. Mainly, I got all of the imports to be in a consistent format, and I rewrote a bunch of test code that was slightly more complicated than it needed to be, and twice as long. This should help future rewrites, because I got rid of most from ... import and import ... as statements, so I can't cause a name collision by adding more modules.

Now I can ponder deep mysteries, like "The implementation of the Action type is irrelevant to the module that explicitly depends on its existence, but it's not even named in the module that does care about the implementation". I'm not sure how to reconcile that with the single-responsibility principle, unless the solution is to make the classes involved generic and only use one type for their type parameter. That sounds weird to me.

I guess I could try moving the type definition, having an import cycle, and trying to make sure it's resolvable, but I'd much rather not have the cycle.

Thinking about this more, I think what I want to do is convert the stuff I'm currently doing by reaching into the Registry class into methods on a Protocol, implement those methods on the concrete class, and then rely on the Protocol and make the Registry class attributes private.

At the very least, I want to make the attributes private and have accessor methods on the Registry; that would have made some previous changes easier. Setting up the Protocol and such is basically a flourish. (Thinking about it, somehow, having a Protocol with type parameters but the only concrete implementation fills all of them in feels less objectionable than a generic concrete class that only uses one parameter value in practice.)

The methods so far would be:

Anyway, it's super late again, so I need to stop writing this and post it.

Good night.