This chapter covers
- How to implement logging
- Abstracting subsystems with the Typed-Untyped design pattern
- Advanced approaches to state handling
- How to safely utilize resources using the Bracket pattern
Different application frameworks may show many similarities in what they offer to developers. Once a new framework enters the development scene, the same subsystems should be implemented repeatedly. Developers who have worked at several companies may confirm that every big-enough project has its own implementation in terms of logging, resource-acquisition mechanism, and integration with external subsystems. Unique implementations are inevitable because implementing a universal approach suitable for all the cases, languages, and domains is nearly impossible.
In this chapter, we will implement some important subsystems such as logging, and given that our main focus is on software design and approaches, we’ll find a couple of new design patterns applicable to this widespread topic. We’ll also learn about advanced state handling and touch briefly on the problem of proper resource management.
10.1 Logging subsystem
Logging is certainly the most essential subsystem of every application framework. It may even be the only subsystem that all the projects have in common. Moreover, it may be the only subsystem we repeatedly introduce and implement during our developer careers.
All the logging subsystems are more or less the same. We can expect to see an interface that