Question

We are receiving an object from a client's webservice that contains two properties : Postcode and Storenumber.

On our side, we need this data frequently so the object is being stored in session and in a cookie. The problem that has arisen is that as a response to some webservice calls to the third party, we will receive only an updated postcode on its own , and for others an updated storenumber.

This would mean that updating the object on our side would involve

  • Checking if the object exists in session
  • If it does - updating only the relevant property
  • Saving it back into the session state

I was thinking to separate the two properties, so the incoming values could used to overwrite the current values, but this feels like an odd approach as I would be separating two values that logically belong together.

I was wondering what your opinion is?

Was it helpful?

Solution

You are considering adjusting your to-storage mechanism to make updates somewhat easier. The expense you incur is to make the consumer's life harder, they would need to fetch two properties.

Generally, I would favour making the consumer's life easier at the expense of making "plumbing" code more complex.

I would always favour data models that most closely represent the business. If Postcode and StoreNumber are strongly related keep them together.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top