- The upgrade path. If you haven't modified the system you want to upgrade and you have no concrete dependencies on its files, then in theory you can upgrade it quite easily, by replacing it.
- Multi-tenant architectures. If you are working in a multi-tenant scenario, then avoiding modifying shared resources can make you life a lot easier, as individual applications are self contained.
With a lot of my work involving Sitecore, I come across these two scenarios quite regularly and up until recently I had strategies for managing:
- Views/Layouts - separation by folder convention
- Sitecore Items - separation by content tree convention
- Sitecore configuration - separation by Sitecore config patching
- .Net configuration - separation by asp .net configuration sections
Now for an example, lets say we are using dependency injection and we want to setup our dependency configuration and then tear it down on application start-up/tear down and we don't want to alter and of the out of the box Sitecore files. The code looks something like:
[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(UnityWebActivator), "Start")] [assembly: WebActivatorEx.ApplicationShutdownMethod(typeof(UnityWebActivator), "Shutdown")] namespace Sample { using System.Linq; using System.Web.Mvc; using Microsoft.Practices.Unity.Mvc; /// <summary>Provides the bootstrapping for integrating Unity with ASP.NET MVC.</summary> public static class UnityWebActivator { #region Public Methods and Operators /// <summary>Disposes the Unity container when the application is shut down.</summary> public static void Shutdown() { } /// <summary>Integrates Unity when the application starts.</summary> public static void Start() { } #endregion } }
The important bits of this are:
- WebActivatorEx.PreApplicationStartMethod - this invokes the specified type/static method combination for the global application start event.
- WebActivatorEx.ApplicationShutdownMethod - this invokes the specified type/static method combination during application shutdown.
Now, armed with this, there is one less file you need to modify from a base Sitecore install.