Design patterns used:
1.Retrofit build process Builder model, factory method model
2. Create network request interface instance Process Appearance mode, Proxy mode, singleton mode, Policy mode, Decoration mode (Builder mode)
3. Generate and execute the request process adapter pattern (proxy pattern, decorator pattern)
The process of creating Retrofit objects uses the Builder pattern, with serviceMethodCache as the core global variable, network request configuration objects, and storage of network request-related configurations such as network request methods, data converters, network request adapters, network request factories, base addresses, etc.
Retrofit.create () uses facade and proxy patterns to create interface instances of network requests.
At its core, Retrofit is just a wrapper around a RESTful HTTP Web request framework. However, it encapsulates OkHttp internally with a number of design patterns that make it very simple and easy to understand for users. Internally, it mainly uses dynamic proxy to dynamically parse the annotation of network request interface into HTTP request, and finally execute the request process.