1

I have an application that has use cases relative to where it is used. A local client and server, where all the server data is in a single location and the client queries that server knowing it is all from that single location.

However the 2nd use case, the client application may connect to several of these location-based servers from which it must know the location from where the data comes.

So in the 1st use case location data is irrelevant, and not necessary to store location. However in the 2nd use case to make querying simple, each record should have a location stored with it.

So my 2 solutions are:

  1. send out location as metadata in queries from each server, create new extended schemas for a database local to the client for cached querying. This would essentially require a 2nd implementation of the client with extended view models.

  2. Both use cases can be satisfied if the location is stored with every schema without having 2 different implementations, but this seems redundant.

Seems a bit overkill if I have to add a location field to every entity or new entity schema, but I think the redundancy is worth it than writing 2 different implementations of the client, or is there a better way?

Im using C# and Postgresql for my server and client apps.

1 Answer 1

2
  1. The client knows the list of locations it is querying and associates each response with its location even though the response doesn't contain the location data

This way allows you to keep your response model true to its purpose. The problem with adding stuff to the model for specific use cases is that the model will become non generic and tightly coupled to its consumers.

3
  • Yes. Implementation wise I would go for a List<Location> and a Dictionary<Location, Data> if grouping by location is necessary. Apr 23, 2022 at 13:10
  • Yes not sure why I didn't think of this, but if I were to access this data offline or from the local cache. this data would essentially still need the connection information to look up on this list. What local caching service or application can help me to do this without having to change my models? May 20, 2022 at 10:14
  • not sure what you mean, just include the id in the cache key "Locations_London", "Locations_Paris"
    – Ewan
    May 20, 2022 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.