Answers
- Yes, asynchronous operations like HTTP are great candidates for the Operation Result pattern. For example, in the Base Class Library (BCL), the
HttpResponseMessage
instance returned by theSend
method of theHttpClient
class is an operation result. - We implemented two static factory methods.
- Yes, returning an object is marginally faster than throwing an exception.
- The Operation Result pattern comes in handy when we want to return the state of the operation along with its return value as part of the main consumption flow. It is very suitable to return multiple properties describing the result of the process and is extensible.
Learn more on Discord
To join the Discord community for this book – where you can share feedback, ask questions to the author, and learn about new releases – follow the QR code below: