Summary
In this chapter, we visited multiple forms of the Operation Result pattern, from an augmented boolean to a complex data structure containing messages, values, and success indicators. We also explored static factories and private constructors to control external access. Furthermore, after all of that exploring, we can conclude that there are almost endless possibilities around the Operation Result pattern. Each specific use case should dictate how to make it happen. From here, I am confident that you have enough information about the pattern to explore the many more possibilities by yourself, and I highly encourage you to.
At this point, we would usually explore how the Operation Result pattern can help us follow the SOLID principles. However, it depends too much on the implementation, so here are a few points instead:
- The
OperationResult
class encapsulates the result, extracting that responsibility from the other system's components (SRP). - We violated the...