Comments on: Basic to Basics: What is Dependency Inversion? Is it IoC? Part 2 https://simpleprogrammer.com/basic-to-basics-what-is-dependency-inversion-is-it-ioc-part-2/ Thu, 12 Apr 2018 05:24:05 +0000 hourly 1 https://wordpress.org/?v=7.0 By: jsonmez https://simpleprogrammer.com/basic-to-basics-what-is-dependency-inversion-is-it-ioc-part-2/#comment-475 Fri, 03 May 2013 15:54:00 +0000 https://simpleprogrammer.com/?p=1173#comment-475 In reply to Budgie Mitchell.

Yep, you are absolutely right. That is one of the reasons why I started this blog… To try and make the complex simple.
IMO, for the most part, if it isn’t simple, it’s wrong.

]]>
By: Budgie Mitchell https://simpleprogrammer.com/basic-to-basics-what-is-dependency-inversion-is-it-ioc-part-2/#comment-474 Fri, 03 May 2013 15:52:00 +0000 https://simpleprogrammer.com/?p=1173#comment-474 In reply to Budgie Mitchell.

BTW I’ll check out your course also 🙂

]]>
By: Budgie Mitchell https://simpleprogrammer.com/basic-to-basics-what-is-dependency-inversion-is-it-ioc-part-2/#comment-473 Fri, 03 May 2013 15:51:00 +0000 https://simpleprogrammer.com/?p=1173#comment-473 In reply to jsonmez.

If the authors of the terms followed their own advice to KISS then we wouldn’t be in this mess, dont you agree? There are many developers running about (me included) thinking they are object oriented experts when in fact their knowledge is lacking or their understanding of a particular paradigm (hate that word) is plain wrong.

]]>
By: jsonmez https://simpleprogrammer.com/basic-to-basics-what-is-dependency-inversion-is-it-ioc-part-2/#comment-472 Fri, 03 May 2013 15:04:00 +0000 https://simpleprogrammer.com/?p=1173#comment-472 In reply to Budgie Mitchell.

I agree with you. Too many definitions. But, it is a history we can’t avoid at this point.

I did a Pluralsight course on IoC that covers all of this in depth, because I wasted to make everything perfectly clear: http://psight.me/ps-ioc

A lot more than what I can type out here.

But, you bring up some great points.

]]>
By: Budgie Mitchell https://simpleprogrammer.com/basic-to-basics-what-is-dependency-inversion-is-it-ioc-part-2/#comment-471 Fri, 03 May 2013 14:53:00 +0000 https://simpleprogrammer.com/?p=1173#comment-471 In reply to jsonmez.

From what I read IoC is also about frameworks, the “don’t call us we’ll call you” principle.

When I read that, I think of a framework like ASP.NET which allows us to plumb in our code when something happens (e.g. Control.OnPreRender(), Control.OnRender() and other overridables) – the framework calls our code when it needs to.

It’s not helpful for so many definitions to be out in the wild, in fact it’s doing my bloody head in! I despair. What should be simple things are being trumped-up to sound esoteric and advanced computing science when they do not need to be, IMHO (this applies to Liskov substitution principle as well)

]]>
By: jsonmez https://simpleprogrammer.com/basic-to-basics-what-is-dependency-inversion-is-it-ioc-part-2/#comment-470 Fri, 03 May 2013 13:52:00 +0000 https://simpleprogrammer.com/?p=1173#comment-470 In reply to Budgie Mitchell.

I read this a few times when researching this article. As well as what Bob Martin had to say.

IMO, it comes down to this.

IoC is a concept. You can invert control in many different ways. In that same article. Martin Fowler asks the question “what control are they inverting?”

Dependency injection is one form of IoC. It just happens to be the most common.

The naming and confusion has made this really bad, and to some degree it doesn’t matter all that much.

We basically end up with 3 things.

1. Dependency Inversion Principle

2. IoC

3. Dependency Injection

Dependency inversion principle is just the idea that you can reverse dependencies.

IoC is just the idea that the actual control of the system can be inverted, through a mechanism like applying the DIP or using Dependency Injection with IoC containers.

Dependency Injection is a concrete way of applying DIP and IoC. It means to actually inject the dependencies of a class into it.

The only reason I think the difference is somewhat important is because many developers think “oh, IoC, DIP, that is all just Dependency Injection.” And, they miss out on other ways to apply the important concept of IoC and what we are really trying to do.

Sure, you can use an IoC container to do dependency injection, but why? You can’t answer why unless you understand the principles behind it.

]]>
By: Budgie Mitchell https://simpleprogrammer.com/basic-to-basics-what-is-dependency-inversion-is-it-ioc-part-2/#comment-469 Fri, 03 May 2013 10:30:00 +0000 https://simpleprogrammer.com/?p=1173#comment-469 Martin Fowler says here:

http://martinfowler.com/articles/injection.html

“As a result I think we need a more specific name for this
pattern. Inversion of Control is too generic a term, and thus people
find it confusing. As a result with a lot of discussion with various
IoC advocates we settled on the name Dependency Injection.”

So, if he says “IoC = Dependency Injection” we should go along with Fowler, yes? My head hurts.

]]>
By: FrenkyB https://simpleprogrammer.com/basic-to-basics-what-is-dependency-inversion-is-it-ioc-part-2/#comment-468 Fri, 03 Aug 2012 11:27:32 +0000 https://simpleprogrammer.com/?p=1173#comment-468 Thanks for answer, nice tool Automapper )) As far as I’ve used it I see only a little performance problem: when I get the list of my objects from EF, I need to map each object to my type of objects. Otherwise the tool is great, I can map easily from EF to classes that are created on data layer. Sometimes I think that follow 100% rules of dependency injection is not possible or it’s not that wrong if you make a reference to – in my case – entity framework library in the GUI layer as long as you use that reference just to show types defined there. After all how (in)dependent modules are can be best shown if you change one module – in my case I need my app to work with MVC and Windows Forms. So I will have to implement both GUI’s. For now I have just Windows Forms.

]]>
By: jsonmez https://simpleprogrammer.com/basic-to-basics-what-is-dependency-inversion-is-it-ioc-part-2/#comment-467 Thu, 02 Aug 2012 20:04:41 +0000 https://simpleprogrammer.com/?p=1173#comment-467 In reply to FrenkyB.

One way to avoid having your GUI layer depend on EF layer is to use DTO or Data Transformation Objects. Basically just classes that look like the same types in the EF layer, but you copy into a new type in the data layer. This would insulate your GUI code from depending on the EF layer code. There are some frameworks for making this easy like Automapper (https://github.com/AutoMapper/AutoMapper.)

It really depends on if you feel you need to isolate from EF. Some might argue that you shouldn’t worry about it because you are not going to change out your data persistence layer, but it really is up to you.

]]>
By: FrenkyB https://simpleprogrammer.com/basic-to-basics-what-is-dependency-inversion-is-it-ioc-part-2/#comment-466 Thu, 02 Aug 2012 18:33:23 +0000 https://simpleprogrammer.com/?p=1173#comment-466 I have a question: I’ve created a project using entity framework as ORM. For entity framework I’ve set class library. Another class library is data layer which connects to entity framework library. I’ve also added project for testing my application and another project (Windows Forms) as my GUI. My question is: in order to show info on the GUI I must reference both data layer and EF. Is this OK or this means too much dependencies? Rerefencing EF from GUI is just because of showing some data types that are defined by entity framework and comes to GUI layer as List.

]]>