August 27, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Dependency Injection with Spring.Net

  • January 22, 2008
  • By David Consdorf
  • Send Email »
  • More Articles »

Testing with Dependency Injection

Another interesting use of Dependency Injection is for unit and integration testing. The ability to swap out different components easily with Spring.Net allows developers to create stub components to test with so they can focus on testing their specific piece of code without needing to worry about other parts of the system being completed and/or working properly.

For example, say you are developing some services for an application's business layer but the data layer is not implemented yet or there are environment restrictions that don't allow you to access the needed data sources. With Spring.Net and Dependency Injection, you still can test the service by creating some mock data components that fill in the missing data layer functionality needed to complete your tests. Then, all you need is a separate Spring.Net configuration using your testing components. Later, when you need to integrate with the real data layer, you can just swap out the testing configuration and put in the integration testing or production configuration.

There are also other testing techniques with Spring.Net including Spring.Net's own testing framework, so if you are interested, check out some other articles focused on the subject or check out the Spring.Net web site: www.springframework.net.

More Spring.Net

It is important to note again that although this article focuses mainly on the Dependency Injection aspects of Spring.Net, there is much more to Spring.Net than object factories. Spring did start with the idea of being a robust configurable object factory, but that idea lent itself well toward expanding outward into a toolset. The whole idea of object factories, after all, is to provide a mechanism for building applications as set of components, so it makes sense that when Spring.Net expands the result is new, reusable components to help solve common problems or implement new ways to build applications.

With that said, make sure to check out www.springframework.net and read more about Spring.Net and what tools it can offer to help you build a great application.

Conclusion

I hope this article helped shed some light on Spring.Net and how it can be an incredible resource for implementing Dependency Injection in you applications. Dependency Injection and Loose Coupling are powerful concepts that will ultimately make your applications more flexible, extendable, and easier to maintain. Be sure to check out Spring.Net for your Dependency Injection needs and also be sure to check out the other wonderful functionality Spring.Net provides.

Code Examples:

To download the example code in this article click here: Download Code Examples.

About the Author:

David Consdorf, Chicago, Illinois

Work Experience

For the last three years, David has been developing Java and ASP.Net web applications as a senior software consultant for Crowe Chizek and Company LLC. Crowe Chizek and Company LLC is a Microsoft Gold Certified Partner.

Education

David graduated with a Bachelor's Degree in Computer Science from the University of Illinois Urbana-Champaign.





Page 6 of 6



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel