|
title: Put the knife down and take a green herb, dude. |
descrip: One feller's views on the state of everyday computer science & its application (and now, OTHER STUFF) who isn't rich enough to shell out for www.myfreakinfirst-andlast-name.com Using 89% of the same design the blog had in 2001. |
|
FOR ENTERTAINMENT PURPOSES ONLY!!!
Back-up your data and, when you bike, always wear white. As an Amazon Associate, I earn from qualifying purchases. Affiliate links in green. |
|
|
x
MarkUpDown is the best Markdown editor for professionals on Windows 10. It includes two-pane live preview, in-app uploads to imgur for image hosting, and MultiMarkdown table support. Features you won't find anywhere else include...
You've wasted more than $15 of your time looking for a great Markdown editor. Stop looking. MarkUpDown is the app you're looking for. Learn more or head over to the 'Store now! |
|
| Thursday, August 26, 2021 | |
|
From microsoft.com:
You know, I've often wondered why dependency injection is so popular. It truly is just an inversion of control. The control concerns themselves don't change. It's another variation of "it's all zeroes and ones" where you rearrange some deck chairs to make things look new again. That's not all bad. Cargo culting is much too popular a development mentality. At least rearranging deck chairs makes people look at their architecture closely with fresh eyes, though I fear the result is often trading one cult for another that has better marketing or community buy-in when the decision to join is made. And I often get the answer highlighted in green when the discussion comes up: "But we have to have interfaces so that we can test it!" Um... not always true. There are other equivalent options. And because there are good ways to test that existed before DI, that's really not a good explaination for its adoption. DI isn't free; it has a significant cost. It requires a good head rethread and a ton of boilerplate. Easier testing doesn't (again imo) explain its explosive popularity. (Though I'm very happy it's become the industry's party line to proclaim we value testing so much.) But this line (highlighted in yellow earlier) from Microsoft actually explains the DI advantage:
I really think that's it -- put another way, DI helps enable clean encapsulation that, in turn, fosters anonymous collaboration between coding teams. If I have to learn how to spin up That's what DI does. It's a decent amount of extra work up front to save everyone down the line from being nickel and dimed -- or, when they're protected from having to learn a whole new domain, dollar and pounded. This shows that DI's advantages clearly appeal to enterprises; DI is literally an enterprise architecture strategy, not to improve system load or because it's an inherently superior -- again, for a small team, the DI boilerplate might ultimately slow them down -- but because it can help enable a specific type of work, which is work by multiple teams and workers with very little knowledge transfer overlap. Enterprise development is really a pretty fascinating study in cultural evolution. Labels: development, DI posted by ruffin at 8/26/2021 06:43:00 PM |
|
| Wednesday, April 27, 2016 | |
|
A few quick additions to yesterday's Thoughts on Dependency Injection...
From the second:
That would have been good to know a few months ago. ;^) That post's real take-home is this, however:
I believe it also rightly argues against overusing lazy-loading. I tend to invoke queries fairly quickly, often forcing EF queries to call the database, with a Know that an overuse of lazy-loading can get you into insanely inefficient queries. That is, just because you're "lazy loading" doesn't mean that you're using your rbdms correctly. You should have what amounts to a query builder inside of your business logic. Understand your use cases, write a view or sproc, and let your rdbms optimize. Don't get lazy with the justification that you're going to lazy load and that it's the same as writing SQL [in that it's work pushed to the dbms]. It's not the same. Also keep in mind that Dependency Injection isn't nearly as fancy as it sounds. I think DI is usually couched in a very specific context that also involves an injection system, making the actual injection a somewhat obfuscated process, as I complained earlier. Getting familiar with all of that system's dependencies can be overwhelming at first glance, but, trust me, the concept itself is simple. AndN .et MVC already has DI installed! Though I can never approve of sleeveless shirts for men in tutorial videos, this one is otherwise quite useful showing how quickly and easily DI can be in a .Net MVC project. And even then, keep in mind how simple Inversion of Control really is. You probably do it a lot already to keep your code defensive and maintainable. You don't want your objects to depend on anything extraneous, so you'll often find yourself sending along something major to help your business objects get their work done. For instance, when you send along event handlers to widgets, that's a sort of IoC already! Told you you were familiar with it. posted by ruffin at 4/27/2016 08:00:00 AM |
|
| Tuesday, April 26, 2016 | |
|
Edit (27 Apr 16): I should've probably led by saying that I am a big fan of Inversion of Control. That also means I'm a decent fan of DI. But I'm also a fan of not over-engineering, and somehow the "culture" around DI is one where over-engineering seems to be fairly commonplace (see the Joel on Software post I talk about, below -- he's not talking about DI specifically, but I think you can inject it (hahahahaha) into his generic critique in this case). I love separation of concerns. What I don't love is hipster programming. If you're never going to reuse something, and it's significant to insane work to abstract it, don't. If abstraction was a bit more, knock yourself out, but, for instance, QueryOver in NHibernate when you're so deeply invested in SQL Server there's no great business case to leave, stop it. If your devs know SQL, stop it already. A better solution to a potential change in stack is to become familiar with microservices, and use them appropriately. The only place I can think of where this sort of gross abstraction might make some sense is when your stack is just getting off of the ground. But then it's no big deal to rip it all up if your old, crufty C# guy leaves and is replaced by Node Grrrl. Was doing some quick reading before talking about Dependency Injection tomorrow, and ran into a link from an SO question to a Joel on Software post I don't think I've run across before, Don't Let Architecture Astronauts Scare You:
Man, that's good. Honestly, Wikipedia currently does an excellent job explaining the pros and cons of Dependency Injection. Here are a few from each...
Okay, I admit it. I kept all of the disadvantages up there. I have worked with a system that overused DI before, and we had it so far upstream of our entities and controllers that you could work for months without ever coming into contact with the construction of a repository. That's not necessarily good. The "explosion of types" was definitely a problem, which means that over-abstraction was as well. "DI! DI! We can run the whole world with DI! DI venture capital funds!" /sigh I like interfaces. And my C# rdbms finally talked its way to using DI. I'm (slowly; I haven't had much time to work with it right now, as I don't have a product for which it's an absolute requirement) factoring it into a portable library, and that means I have to inject a class in that writes to files. Not a big deal, and certainly The Right Way to do it. What I dislike is when the DI is so abstracted that you're essentially cargo culting your way through repo instantiation, where you can create a repo from scratch and the inheritance hides that some base class is doing all the DI for you. That is, it's way too easy to end up in that last "con" from above: "Ironically, dependency injection can encourage dependence on a dependency injection framework." Wikipedia has an interesting link to some Uncle Bob Consulting jive. I haven't closely read it all, but some of this rings true on first skim...
That sounds about right, though it also seems to create a situation where you've got at least one of the "secret module" situations he was trying to avoid. The takehome message when considering Dependency Injection? Never outsmart yourself. Or, as Zakas put it a while back, "don't be too clever". posted by ruffin at 4/26/2016 01:33:00 PM |
|
|
| |
|
|
All posts can be accessed here: Just the last year o' posts: |
|||||||||||||||||||||
|
||||||||||||||||||||||
|
|
|
|