Extending the BookSwap application with generics
So far, we have seen how to write a generic function and use generics to write easier test utilities. This has already proven to be a very powerful mechanism, providing us with both flexibility and type safety, something which cannot be achieved by an empty interface. In this section, we will learn how to make use of generics in our example REST API, the BookSwap
application.
Let us suppose that the BookSwap
application wants to extend its business model and begin swapping magazines, alongside its regular books business model. Figure 11.3 presents the new system diagram for the application:
Figure 11.3 – The extended BookSwap application
The preceding example considers the BookSwap
application’s monolithic architecture, but the same kind of considerations would apply to microservices architectures as well. Changes would have to be made throughout the application to support a new model, starting...