Archives
-
System.ComponentModel
With much of the Java and OO world discussing Inversion of Control (IoC) patterns, also dubbed "dependency injection" by Martin Fowler, its worth remembering that the .NET Framework has always included a "service locator" pattern which allows a component to access shared "services".
It can be used to support a pattern which provides a mechanism by which one can loosely-couple components - i.e. eliminate hard coded dependencies between objects. [For those lightweight container aficionados here, .NET's implementation provides for Type 1 (interface) IoC injection of a "Service Locator" into each .NET Component]
It's widely used in the Framework and in tools like Microsoft Visual Studio. For example, it underpins the Windows Forms Designer architecture, and it is the mechanism through which Windows Forms Controls inherit aspects of the underlying Form. You could use it to share say a particular ToolBar across Forms, but it goes much further than that - really to the heart of OO and how one can wire together objects without introducing hard-wired dependencies.