My use case is that I am making requests to various APIs that return different external data types. Then I have to decorate the data with additional metadata that I retrieve from other APIs. Then I return a response depending on what clients want.
First I am making requests for the data, and based on those results, I am retrieving the appropriate metadata for each piece of data.
My approach so far:
- Call APIs and receive external types
- Convert external types to an internal interface with Adapter pattern
- Call other APIs to retrieve metadata for each data piece
- Mutate the adapted internal object with Visitor pattern
- Format the internal object appropriately for the client
I'm concerned about #3 (EDIT: I'm concerned about #4, not #3). Is using Visitor pattern on adapted internal types appropriate or is there an easier way? Would it be a good practice to create Visitor operations that each mutate the objects in sequence, in different ways? (i.e. setting fields in the list of data objects)