Revisiting the Singleton pattern
The Singleton pattern is obsolete, goes against the SOLID principles, and we replace it with a lifetime, as we've already seen. This section explores that lifetime and recreates the good old application state, which turns out to be nothing more than a singleton scoped dictionary.
We'll explore two examples here; one about the application state, in case you wondered where that feature disappeared to. Then, the Wishlist project also uses the singleton lifetime to provide an application-level feature. There are a few unit tests as well to play with the testability and to allow safe refactoring.
The application state
If you programmed ASP.NET using .NET Framework, or the "good" old classic ASP with VBScript, you might remember the application state. If you don't, the application state was a key/value dictionary that allowed you to store data globally in your application, shared between all sessions and requests. That is...