4 ms·
Author here. After posting this to reddit I realized that the original title is wrong, and poorly reflects the actual point I'm trying to make. Dependency injec
by glun 7y ago
Author here. After posting this to reddit I realized that the original title is wrong, and poorly reflects the actual point I'm trying to make. Dependency injection is not dynamic scoping, but the latter can be used to achieve the former. I'm drafting an update to better reflect this. I'm also going to pull out reader monads and env passing into separate sections and give reader monads a better treatment in general.
- donw 7y agoGood on you for coming here to clarify! :)
- mcherm 7y agoI really liked this essay -- I found it very clearly explained and it pointed out something I ought to have known but somehow had never previously realized. My only complaint is that when I went to go read through the other articles on your blog and perhaps add it to my RSS feed there weren't any other articles! This wasn't the first thing you have written... is there a place I can read some of the others?
- glun 7y agoThank you. This warms my heart to hear. However, this is the first thing Ive written outside of isolated reddit comments. But I do have a backlog with a few articles that I have mapped out but havent gotten around to writing yet.
- HereBeBeasties 7y agoPlease do. IMO, this was very well written, well-paced and interesting.
- mercer 7y agoSeconding the sibling comment that I'd love to read more of your posts, and the most likely way I'll notice a new post is if the RSS feed works :).
- eternalban 7y agoThe 'Env' is typically called 'Context'. These mechanisms are addressing functional requirements in component oriented systems, but in the industry have been misunderstood and misused to satisfy testing requirements. And if one is not doing pervasive component reuse across multiple systems and projects, the on-off usage of DI is of course completely over-engineered and likely a poor design decision.
- mrec 7y agoAnd one obvious refinement of the `Env`/`Context` God-dependency pattern is to have it implement a bunch of fine-grained interfaces for subsets of the dependencies it aggregates, so that you can both reduce plumbing (only one thing to inject) and still make it clear which specific dependencies a given call might use.
- DaiPlusPlus 7y agoHow would you manage scoped lifetimes and transient objects using the Env/Context pattern?
- eternalban 7y agoI creatd a minimal framework in C++ in mid '90s around the concept of Contextual Objects. Child contexts can be used to affect life-cycle scopes. In this approach, the virtual construct of a 'containment context' allows for managed life-cycles, at an aggregate level. Delete the context and all child objects (recursively) are deleted as well.
- Gibbon1 7y agoYour essay reminded me of the local function extension in gcc. A local function has access to the variables in scope when it was defined.
- inetknght 7y ago> Author here. Can you make it so your site uses HTTPS? Can you make it so it doesn't just load an frame pointing to Github.io? Both combined seem very sketchy to me.
- z3t4 7y agoIf the title was less click-baity I probably wouldn't have read your article. The article itself was perfect. It was short enough, and it was informative enough. If you want to expand on a subject it's probably better to make a new URL and link to it, or if good articles already exist, link to those.
- eru 7y agoI like that the examples were in a range of different languages. Not sure how well that works for other people, but I think the way you wrote it makes them understandable even for eg people who don't really know Java.
- moljac024 7y agoCan you share a link to the reddit discussion? I tried searching but I couldn't find the post.
- ScottBurson 7y agoThere's an example of dynamically scoped variables that will be familiar to almost everybody: environment variables, which are passed dynamically across program invocations.