concept section in category dependency injection

This is an excerpt from Manning's book Dependency Injection.
You may never have come across or heard of DI before, and that’s great. Skip this section and go straight to section 1.1.2. But, if you’re reading this book, it’s likely you’ve at least come across it in conversation, in a code base you inherited, or in blog posts. You may also have noticed that it comes with a fair amount of heavy opinions. In this section, we’re going to look at four of the most common misconceptions about DI that have appeared over the years and why they aren’t true. These myths include the following:
Listing 6.7
INotificationServicewith a growing number of methodspublic interface INotificationService { void OrderApproved(Order order); #1 void OrderCancelled(Order order); #1 void OrderShipped(Order order); #1 void OrderDelivered(Order order); #1 void CustomerCreated(Customer customer); #1 void CustomerMadePreferred(Customer customer); #1 } #1 Each method represents a domain event. Abstractions with many members, however, typically violate the Interface Segregation Principle, which we'll discuss in section 6.2.1.

This is an excerpt from Manning's book Dependency Injection in .NET.
Figure 1.12. The Hello DI application from section 1.2 contains a SEAM between the Salutation and ConsoleMessageWriter classes because the Salutation class only writes through the ABSTRACTION of the IMessageWriter interface.
![]()
In section 1.2.1, you didn’t use late binding because you explicitly created a new instance of IMessageWriter by hard-coding creation of a new ConsoleMessageWriter instance. However, you can introduce late binding by changing only a single piece of the code. You only need to change this line of code:
Sometimes we can’t use a generic API because we don’t know the appropriate type at design time. All we have is a Type instance, but we’d still like to get an instance of that type. You saw an example of that in section 7.2, where we discussed ASP.NET MVC’s DefaultControllerFactory class. The relevant method is this one:
The LifecycleIs method takes an instance of ILifecycle, so you can pass in any class that implements that interface. As you’ll see in section 11.2.2, this is also how we configure a component with a custom lifetime.
All built-in StructureMap lifestyles have a corresponding ILifecycle implementation except the PER GRAPH lifestyle, which is the default. This lifestyle is normally implicitly configured by omitting an explicit lifestyle. All the configurations you saw in section 11.1 used the PER GRAPH lifestyle.
When we need to define components in XML, we’ll also want to be able to configure their lifestyles in the same place. This is easily done as part of the XML schema introduced in section 11.1.2. You can use the optional Scope attribute to declare the lifestyle:
<DefaultInstance PluginType="Ploeh.Samples.MenuModel.IIngredient, Ploeh.Samples.MenuModel" PluggedType="Ploeh.Samples.MenuModel.Steak, Ploeh.Samples.MenuModel" Scope="Singleton" />Compared to the example in section 11.1.2, the only difference is the added Scope attribute that configures the instance as a SINGLETON. When you previously omitted the Scope attribute, StructureMap’s PER GRAPH default was automatically used.