1

I am using a 3rd party API which yields JSON which has two ways of loading data - as a list of items, or as a singular item. The problem is that a given item in the list has different properties than the same item if you load it as an individual. The two load methods yield items which are similar, but different.

For example, an item in the list has a property called "amount", while on the singular load the same thing is called "grand_total". Likewise, in the list there is a string property called "vendor", but in the singular load the same property is an object.

Given that I cannot go back in time and make an independent company write a sensible API, I am left to create two classes (in C#) to work with these things.

Is there a good naming strategy for these items? As in, if the item is a "foo", should I have a "foo_list" class and a "foo" class? It feels ugly any way you slice it.

  • 7
    did you consider making Anti-Corruption layer around poorly designed API? – gnat Jun 3 '16 at 3:26
  • gnat has an excellent suggestion. Make a wrapper API that hides the ugliness. And simplify it so both methods of loading appear similar. – Frank Hileman Jun 9 '16 at 20:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.