@hynek I like what I see, can it layer contexts/disposal/dependency?
We have a little monster in pytest for managing fixture's
@ossronny yes, they’re much better.
The container is an `with closing(container)` context manage and the factories are pytest-style generators. MUCH more ergonomic in practice.
@hynek all of the frameworks model their needs as they grow, the results are molded by fate
I'd like to get to a place where collaboration gets us out of that trap
@ossronny I’ve been using this for years, so this is not a first attempt to solve a problem, it’s _my_ trade-off at comprehensibility vs functionality.
It always depends what you compare it to. I compare it to the boilerplatey get_x (Flask) and add_request_method (Pyramid) patterns. Got it working with FastAPI too, which gets super verbose with its own DI once you have more than 2 dependencies.
I think if the present audience is really that small, it's okay to let the package speak for itself for now. You will continue to extract value from it personally until the audience grows large enough for it to be worth proper thorough communication.
If the target audience is growing, you'll get many more chances at first impressions even a year down the road than today, and maybe the API will have hardened a bit by then and it'll also be easier to communicate.
@hynek ah, yes, so it appears I was familiar with the idea from my previous job, but not the name.
Let me rephrase to see if I've understood:
The term "dependency injection" is specifically about your code getting its dependency as input arguments. Service locator is a different mechanism, that shares a common goal.
Aside from that, hexagonal architecture cares more about where you draw your lines, what you call your components and interfaces.
@hynek so to put that together in a sentence:
My previous job was using a hexagonal architecture, with different components for the http views, the business logic, the database access, and the network call to other services.
All of this was tied together with dependency injection (implemented is scala as argument to classes, with the glue being one big main that instances everything in order).
Does that sound coherent with what you were explaining in the glossary?
@georges yep sounds mostly right to me! hexagonal is mostly about thinking more clearly about components and less about “layers” (each component can have arbitrary layers, too).
and the diff between injection and locator is literally just the acquisition mechanism with upsides and downsides on both side. it’s explained a bit deeper in https://svcs.hynek.me/en/latest/why.html#is-this-dependency-injection – I should probably transplant some of the text
@hynek thanks, things are now way more clear in my head than they were this morning :)
It also looks like on that topic I should resume reading Architecture Patterns with Python. (And wrap my head around how to use sqlalchemy properly in this context)