concept application in category dependency injection

This is an excerpt from Manning's book Dependency Injection.
In this context, late binding refers to the ability to replace parts of an application without recompiling the code. An application that enables third-party add-ins (such as Visual Studio) is one example. Another example is the standard software that supports different runtime environments.
Suppose you have an application that runs on more than one database engine (for example, one that supports both Oracle and SQL Server). To support this feature, the rest of the application talks to the database through an interface. The code base provides different implementations of this interface to access Oracle and SQL Server, respectively. In this case, you can use a configuration option to control which implementation should be used for a given installation.
The analysis of Mary’s application in chapter 2 concluded that Volatile Dependencies were tightly coupled across the different layers. As the dependency graph of Mary’s application in figure 3.1 shows, both the domain layer and the UI layer depend on the data access layer.
By creating this inversion, we allow the data access layer to be replaced without having to completely rewrite the application. (This is a radical departure from the way Mary developed her application.) We’ll also apply several patterns along the way. Then we’ll apply Constructor Injection, which we discussed in chapter 1. And finally, we’ll also use Method Injection and Composition Root, which we’ll discuss as we go.
This approach will lead to quite a few more classes as we focus on separating the application concerns. Where Mary defined four classes, we’ll define nine classes and three interfaces. Figure 3.3 drills a little deeper into the application and shows the classes and interfaces we’ll create throughout this chapter.
Figure 3.3 The classes and interfaces that we’ll have at the end of this chapter. Interfaces are marked with dashed lines.
![]()
Figure 3.4 shows how the main classes in the application will interact. At the end of this chapter, we’ll take a look at a slightly more detailed version of this diagram again.
Listing 3.13 The application’s object graph
new HomeController( new ProductService( new SqlProductRepository( new CommerceContext(connectionString)), new AspNetUserContextAdapter()));

This is an excerpt from Manning's book Dependency Injection in .NET.
Unit tests provide rapid feedback on the state of an application, but it’s only possible to write unit tests when the unit in question can be properly isolated from its DEPENDENCIES. There’s some ambiguity about how granular a unit really is, but everyone agrees that it’s certainly not something that spans multiple modules. The ability to test modules in isolation is very important in unit testing.
It’s only when an application is susceptible to unit testing that it’s considered TESTABLE. The safest way to ensure TESTABILITY is to develop it using Test-Driven Development (TDD).
The application entry point in ASP.NET is the global.asax file, and although you can’t compose anything at this point, you can create your mise en place, making everything ready for when the application starts:
protected void Application_Start(object sender, EventArgs e) { this.Application["container"] = new CampaignContainer(); }The only thing you do here is to create your container and save it in the Application Context so you can use it when you need it. This allows you to share the container across separate web requests, which is beneficial if you need to keep some DEPENDENCIES for the duration of the process’s lifetime (we’ll talk more about lifetimes in chapter 8).
The previous example developed a web service we can use to manage the product catalog for the sample Commerce application. In this example, you’ll create a WPF application that uses this web service to manage products. Figure 7.10 shows a screen shot of the application.
Figure 7.11. The application consists of three distinct assemblies. The ProductManagementClient assembly is the executable and contains the UI implemented in XAML with no code-behind. The PresentationLogic library contains the ViewModels and supporting classes, and the ProductWcfAgent library contains an Adapter between the custom IProductManagementAgent ABSTRACTION and the concrete WCF proxy that is used to communicate with the product-management web service. The dependency arrows imply that ProductManagementClient acts as the COMPOSITION ROOT, because it wires together the other modules.
![]()

This is an excerpt from Manning's book Dependency Injection: Design Patterns Using Spring and Guice.
These external sources may reside in the same application, machine, or local area network, or they may not. Consider an interface to the NASA Mars Rover several millions of miles away, a simple library for text processing, bundled within an application, or a Remote Enterprise Java Bean (EJB).[2] Look at figure 1.8 for a visual.
The Guice.createInjector() method is a varargs method, meaning that it takes any number of arguments. This is convenient for us as we can pass in our two modules, services and servlets, that configure our persistence and security, respectively. Note that Google Sitebricks web pages are processed by the SitebricksModule. We’ll look at the services module in some more detail shortly, but first, let’s examine the application’s package structure.