concept core in category asp.net

appears as: core, core, The core
ASP.NET MVC 2 in Action

This is an excerpt from Manning's book ASP.NET MVC 2 in Action.

This inherent lack of testability is one of the challenges that ASP.NET overcame with version 3.5 SP1. ASP.NET versions 1.0 through 3.5 weren’t built with testability in mind. Even though System.Web.Abstractions.dll contains abstract wrappers around so much of the core of ASP.NET, some parts, like caching, are still very concrete. To cope with this, we can wrap the cache in our own interface. Listing 7.2 shows wrapping the cache with an abstraction, and listing 7.3 demonstrates using the ICache interface. Listing 7.4 shows the test.

The solution structure implements the decoupling strategy that the onion architecture requires. In figure 23.3, you can see this structure with the Core project’s references expanded. The application has a simple core, and the libraries referenced to implement the core are straightforward.

Figure 23.3. The Core project has minimal references and no external dependencies.

Notice that there’s no reference to NHibernate.dll from the Core project. It’s important that the core remain portable and not coupled to external libraries that will change over time. As time goes on, the libraries you use will change, as will the versions of the libraries. Keeping the core free from this churn will keep it stable. As with everything in software, this is a trade-off. You may feel comfortable coupling to some libraries, but be sure to evaluate the consequences carefully. This example employs the Inversion of Control (IoC) principle through abstract factories and dependency injection.