November 01, 2010

Dependency Injection

Loose coupling i.e. making your code modules less tightly bound to each other.
Dependency Injection helps this process, allowing clients of your code to get the application using their own code without them having to know very much at all as to how the application works internally.

The article linked in the title of this post has a very brief outline of some how it can work but basically I'm interested in using Interfaces and registering my own classes with the host application with the minimum possible code work.

There are lots of third party frameworks which provide implementations.
The method is usually the same, create and instance of the third party class and then call a method on it which tells the framework to run a particular concrete class that you have provided when a particular interface or type is used, it's a form of mapping allowing client classes to be used at runtime.

4 comments:

Magento Themes said...

Loose coupling and making your code modules less tightly bound to each other.
Dependency Injection helps this process, comes from C++, thats why it is to learn

Web Design Firm said...

@ Megento Themes, you remind me that old beautiful language which is mother all these modern programming languages. My beautiful C++.

- Tanya
Web Design Firm

Magento Templates said...

@Tanya...

The power which the language of C++ is being able to provide is surely the best when it comes to creating a website....
Well done keep up your efforts

Magento Themes

Chloe said...

Thanks for sharing an outstanding post and telling as to what all is the importance of Dot Net.... Thanks a lot for posting....

Commercial Buildings for Sale