mercredi 9 mars 2016

Are Adapter and Visitor patterns appropriate for my use cases?

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:

  1. Call APIs and receive external types
  2. Convert external types to an internal interface with Adapter pattern
  3. Call other APIs to retrieve metadata for each data piece
  4. Mutate the adapted internal object with Visitor pattern
  5. Format the internal object appropriately for the client

I'm concerned about #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)

Aucun commentaire:

Enregistrer un commentaire