views:

260

answers:

2

In dynamic languages such as Ruby and Python, the concept of a formal IOC pattern with a traditional (for us static guys) interface-driven implementation doesn't exist.

Will C#'s upcoming Dynamic type cause or at least enable the need for static IOC patterns to be eliminated? That MS's P&P Unity project takes 231 pages of documentation boggles my mind. Surely a better way lurks!

+1  A: 

I personally would not want to remove my IoC stuff for the use of Dynamic typing. I want strongly typed code when and where possible and dynamic typing only when I can't do otherwise or when I am working with Com or javascript. Using dynamic typing simply to remove IoC pattern sounds like a code smell to support TDD! IoC still remains the cleanest way to do testing and decoupling. ...at least in my mind.

Andrew Siemer
I'm not suggesting that existing code be ripped and replaced--I understand that. But the dynamic stuff coming seems like a great way out of the static IOC tarpit.
rp
I love the way IoC works. It makes my code more readable as the dependencies are stated up front. Also using a tool like StructureMap has very little configuration overhead and allows my application huge flexibility allowing me to inject different types of implementations of the same "thing". The IoC pattern allows me to test more easily and allows me to control what is injected. The IoC container provides added value for swapping and configuring. This is more than Dynamic typing will give me!
Andrew Siemer
Andrew--one more thing... Did you look at Castle Windsor, too? What other IOCs did StructureMap beat for you? Thanks.
rp
+2  A: 

They solve different issues. One of the issues with auto-wiring IoC in something like JS is the lack of static typing - so dynamic types work against one of the big benefits of IoC.

That being said, there's no reason that dynamic types can't be used for receiving IoC components in some situations, and there may be some use there - we shall see.

Luke Schafer