What is Dependency injection?
A software concept at which when an object relies on another one in its functionality the using object is not responsible for knowing how the needed object will be available . In other words; when an object have a reference to another object as a member variable, it is not responsible for determining how that reference will be available.
Suppose the next fragment of code:
public class car
public Engine engine;
Public void GO(int Acceleration_Factor)
public class Engine
public SparkPlug sparkplug;
public void Start()
It is clear that we are demonstrating a simple car operation which consists of an engine with a simple spark plug. ok, lets review this case in terms of code. When you instantiate an object of type car, you have to supply it with an object of type engine which in turn needs an object of type spark plug which might need another object of another type and so on.
Imagine a way to let you just specify the characteristics of your objects and the creation is some one else's concern, imagine that when you create the car object, the engine object is created and ready for use which in turn have a spark plug object created and ready for use.
doesn't make sense yet?? Ok, lets see this scenario.
Suppose you need to unit test the previously mentioned example, a test case will be written, so all what you need is to test the functionality of the car object assuming it has more references to objects rather than an engine. When you write this kind of test, you have to successfully create an engine object, which requires the creation of a spark plug object, those last creations are totally out of scope for testing the car object. In this case, all what you need is some one who creates these objects for you in the right way to make sure that you are only testing the car object, That "some one" is the Dependency injection frame work.
Frameworks like spring offer this feature, all what you do is specifying what your business objects look like in an XML file, and the framework is responsible for supplying any other objects using your objects. It might not be clear that this is an amazing feature, but in enterprise applications, relations between objects get very complicated and dependencies might be cyclic at some points, where an object depend on another which in turn depend on another which depends on the first one. In real cases; dependency injection become very useful, you just declare your variables and generate their accessors and the frame work does the rest.
The importance of dependency injection might not be clear by now, but when you start writing code with this trend you will notice the difference.
Saturday, October 27, 2007
What is Dependency injection?
Gmail is starting to roll this protocol IMAP (Internet Message Access Protocol) out on every device and every platform, for free.
This protocol have a advantage than the previous old supported protocol POP ( supported until now ) , in fact it seem like POP(Post Office Protocol) access, but lacks one critical feature: your changes made on other devices aren't seen in Gmail when you log back in (you must log in again to get changes ).
Official Google Blog :
Posted by Ahmed Essawy at 10/27/2007 02:57:00 AM
Saturday, October 20, 2007
I got that from Channel 8 recent news, F# is an official .NET language now
Soma had the news today. F# is an official .NET language now! Functional programming becomes a first citizen in .NET :-) read more...
Friday, October 19, 2007
Tuesday, October 16, 2007
They consider this new release candidate to be complete, stable, and suitable for testing by any user.The new version 7.10 is scheduled for 18 October 2007 (after two days ) and will have supporting for 18 month only so from users want support for longer time using Ubuntu 6.06 LTS, with security support until 2011 .
Sunday, October 07, 2007
in the name of ALLAH
actually um like Most of you, when i read this title in ScottGu's Blog,
Microsoft gonna make FW 3.5's Libraries be open source .. WOW.. So excited
Read this Part from his Post
One of the things my team has been working to enable has been the ability for .NET developers to download and browse the source code of the .NET Framework libraries, and to easily enable debugging support in them.
Today I'm excited to announce that we'll be providing this with the .NET 3.5 and VS 2008 release later this year.
We'll begin by offering the source code (with source file comments included) for the .NET Base Class Libraries (System, System.IO, System.Collections, System.Configuration, System.Threading, System.Net, System.Security, System.Runtime, System.Text, etc), ASP.NET (System.Web), Windows Forms (System.Windows.Forms), ADO.NET (System.Data), XML (System.Xml), and WPF (System.Windows). We'll then be adding more libraries in the months ahead (including WCF, Workflow, and LINQ). The source code will be released under the Microsoft Reference License (MS-RL).
You'll be able to download the .NET Framework source libraries via a standalone install (allowing you to use any text editor to browse it locally). We will also provide integrated debugging support of it within VS 2008.
to read the Full Post from here